Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial refactor of the plugin structure. (#406)
* Initial refactor of the plugin structure. The short-term/immediate goal is to introduce a place for projects to indicate whether javadoc needs to be generated for them, it's done here via `firebaseLibrary.publishJavadoc`. The long-term vision is to move all build and release logic be controlled via the 'firebase-library' plugin instead of it being injected into individual projects from the root-project. * Fixes * Update. * Fix formatting and license
- Loading branch information
Showing
26 changed files
with
302 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.gradle.plugins; | ||
|
||
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension; | ||
import javax.inject.Inject; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.model.ObjectFactory; | ||
|
||
public class FirebaseLibraryExtension { | ||
public boolean publishJavadoc = true; | ||
public boolean publishSources; | ||
public final FirebaseTestLabExtension testLab; | ||
|
||
@Inject | ||
public FirebaseLibraryExtension(ObjectFactory objectFactory) { | ||
this.testLab = new FirebaseTestLabExtension(objectFactory); | ||
} | ||
|
||
void testLab(Action<FirebaseTestLabExtension> action) { | ||
action.execute(testLab); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.gradle.plugins; | ||
|
||
import com.android.build.gradle.LibraryExtension; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.bundling.Jar; | ||
|
||
public class FirebaseLibraryPlugin implements Plugin<Project> { | ||
@Override | ||
public void apply(Project project) { | ||
project.apply(ImmutableMap.of("plugin", "com.android.library")); | ||
|
||
FirebaseLibraryExtension firebaseLibrary = | ||
project | ||
.getExtensions() | ||
.create("firebaseLibrary", FirebaseLibraryExtension.class, project.getObjects()); | ||
|
||
LibraryExtension android = project.getExtensions().getByType(LibraryExtension.class); | ||
|
||
android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab)); | ||
|
||
// TODO(vkryachko): include sources in firebasePublish | ||
project.afterEvaluate( | ||
p -> { | ||
if (firebaseLibrary.publishSources) { | ||
|
||
p.getTasks() | ||
.create( | ||
"sourcesJar", | ||
Jar.class, | ||
jar -> { | ||
jar.from(android.getSourceSets().getByName("main").getJava().getSrcDirs()); | ||
jar.setClassifier("sources"); | ||
}); | ||
} | ||
}); | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
.../main/groovy/com/google/firebase/gradle/plugins/ci/device/FirebaseTestLabExtension.groovy
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
...rc/main/groovy/com/google/firebase/gradle/plugins/ci/device/FirebaseTestLabExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.gradle.plugins.ci.device; | ||
|
||
|
||
import org.gradle.api.model.ObjectFactory; | ||
import org.gradle.api.provider.SetProperty; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class FirebaseTestLabExtension { | ||
private final SetProperty<String> devices; | ||
private boolean enabled; | ||
|
||
@Inject | ||
public FirebaseTestLabExtension(ObjectFactory objectFactory) { | ||
devices = objectFactory.setProperty(String.class); | ||
} | ||
|
||
public void setEnabled(boolean value) { | ||
enabled = value; | ||
} | ||
|
||
public boolean getEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void device(String device) { | ||
devices.add(device); | ||
} | ||
|
||
Set<String> getDevices() { | ||
if( devices.get().isEmpty()) { | ||
return Collections.singleton("model=Pixel2,version=27,locale=en,orientation=portrait"); | ||
} | ||
return devices.get(); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
...src/main/groovy/com/google/firebase/gradle/plugins/ci/device/FirebaseTestLabPlugin.groovy
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...c/src/main/groovy/com/google/firebase/gradle/plugins/ci/device/FirebaseTestLabPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.gradle.plugins.ci.device; | ||
|
||
import com.android.build.gradle.BaseExtension; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
|
||
/** | ||
* Firebase Test Lab Integration plugin. | ||
* | ||
* @deprecated For library projects use 'firebase-library' plugin instead. App projects should still | ||
* use this plugin. | ||
*/ | ||
@Deprecated | ||
public class FirebaseTestLabPlugin implements Plugin<Project> { | ||
@Override | ||
public void apply(Project project) { | ||
FirebaseTestLabExtension extension = | ||
project | ||
.getExtensions() | ||
.create("firebaseTestLab", FirebaseTestLabExtension.class, project.getObjects()); | ||
extension.setEnabled(true); | ||
BaseExtension android = (BaseExtension) project.getExtensions().getByName("android"); | ||
android.testServer(new FirebaseTestServer(project, extension)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
version=16.0.0 | ||
android.enableUnitTestBinaryResources=true | ||
android.enableUnitTestBinaryResources=true | ||
firebaseJavadoc=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.