diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt index 82477b0d74d..f538f9e10c4 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt @@ -18,11 +18,13 @@ package com.google.firebase.gradle.plugins import com.android.build.gradle.LibraryExtension import com.google.firebase.gradle.plugins.ci.Coverage +import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension import java.io.File import java.nio.file.Paths import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.ProjectDependency +import org.gradle.api.provider.Provider import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPublication @@ -138,9 +140,9 @@ abstract class BaseFirebaseLibraryPlugin : Plugin { firebaseLibrary.artifactId.get() // these dont get populated until afterEvaluate :( groupId = firebaseLibrary.groupId.get() - firebaseLibrary.applyPomCustomization(pom) + firebaseLibrary.customizePom(pom) firebaseLibrary.applyPomTransformations(pom) - from(components.findByName(firebaseLibrary.type.componentName)) + from(components.findByName(firebaseLibrary.type.get().componentName)) } } } @@ -209,7 +211,7 @@ abstract class BaseFirebaseLibraryPlugin : Plugin { // TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types fun FirebaseLibraryExtension.resolveAndroidDependencies() = resolveExternalAndroidLibraries() + - resolveProjectLevelDependencies().filter { it.type == LibraryType.ANDROID }.map { it.mavenName } + resolveProjectLevelDependencies().filter { it.type.get() == LibraryType.ANDROID }.map { it.mavenName.get() } /** * A list of project level dependencies. @@ -221,8 +223,8 @@ fun FirebaseLibraryExtension.resolveAndroidDependencies() = */ // TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types fun FirebaseLibraryExtension.resolveProjectLevelDependencies() = - project.configurations - .getByName(runtimeClasspath) + project.get().configurations + .getByName(runtimeClasspath.get()) .allDependencies .mapNotNull { it as? ProjectDependency } .map { @@ -245,8 +247,8 @@ fun FirebaseLibraryExtension.resolveProjectLevelDependencies() = */ // TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types fun FirebaseLibraryExtension.resolveExternalAndroidLibraries() = - project.configurations - .getByName(runtimeClasspath) + project.get().configurations + .getByName(runtimeClasspath.get()) .incoming .artifactView { attributes { attribute("artifactType", "aar") } } .artifacts @@ -296,5 +298,5 @@ val FirebaseLibraryExtension.latestVersion: ModuleVersion */ val FirebaseLibraryExtension.namespace: String get() = - project.extensions.getByType().namespace - ?: throw RuntimeException("Project doesn't have a defined namespace: ${project.path}") + project.get().extensions.getByType().namespace + ?: throw RuntimeException("Project doesn't have a defined namespace: ${project.get().path}") diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt index c4cd9de6019..5e4ca45028c 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt @@ -122,7 +122,7 @@ abstract class DackkaPlugin : Plugin { // TODO(b/270576405): remove afterEvalutate after fixed project.afterEvaluate { - if (weShouldPublish(this)) { + if (weShouldPublish(this).get()) { val dackkaOutputDirectory = provider { fileFromBuildDir("dackkaRawOutput") } val transformedFilesDirectory = provider { fileFromBuildDir("dackkaTransformedFiles") } diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseJavaLibraryPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseJavaLibraryPlugin.kt index 0638a300bb3..f1bb2ece5bb 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseJavaLibraryPlugin.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseJavaLibraryPlugin.kt @@ -48,8 +48,9 @@ class FirebaseJavaLibraryPlugin : BaseFirebaseLibraryPlugin() { private fun setupFirebaseLibraryExtension(project: Project) { val firebaseLibrary = - project.extensions.create("firebaseLibrary", project, JAVA) + project.extensions.create("firebaseLibrary") + firebaseLibrary.commonConfiguration(project, JAVA) setupStaticAnalysis(project, firebaseLibrary) setupApiInformationAnalysis(project) getIsPomValidTask(project, firebaseLibrary) @@ -59,33 +60,36 @@ class FirebaseJavaLibraryPlugin : BaseFirebaseLibraryPlugin() { private fun setupVersionCheckTasks(project: Project, firebaseLibrary: FirebaseLibraryExtension) { project.tasks.register("gmavenVersionCheck") { - groupId.value(firebaseLibrary.groupId.get()) - artifactId.value(firebaseLibrary.artifactId.get()) + groupId.value(firebaseLibrary.groupId) + artifactId.value(firebaseLibrary.artifactId) version.value(firebaseLibrary.version) - latestReleasedVersion.value(firebaseLibrary.latestReleasedVersion.orElseGet { "" }) + latestReleasedVersion.value(firebaseLibrary.latestReleasedVersion.orElse("")) } project.mkdir("semver") project.tasks.register("copyPreviousArtifacts") { dependsOn("jar") project.file("semver/previous.jar").delete() - groupId.value(firebaseLibrary.groupId.get()) - artifactId.value(firebaseLibrary.artifactId.get()) + groupId.value(firebaseLibrary.groupId) + artifactId.value(firebaseLibrary.artifactId) aarAndroidFile.value(false) filePath.value(project.file("semver/previous.jar").absolutePath) } - val currentJarFile = - project - .file("build/libs/${firebaseLibrary.artifactId.get()}-${firebaseLibrary.version}.jar") - .absolutePath + val currentJarFile = firebaseLibrary.artifactId.flatMap { artifactId -> + firebaseLibrary.version.map { version -> + project.file("build/libs/$artifactId-$version").absolutePath + } + } val previousJarFile = project.file("semver/previous.jar").absolutePath + val previousVersion = firebaseLibrary.artifactId.flatMap { artifactId -> + firebaseLibrary.groupId.map { groupId -> + GmavenHelper(groupId, artifactId).getLatestReleasedVersion() + } + } project.tasks.register("semverCheck") { currentJar.value(currentJarFile) previousJar.value(previousJarFile) version.value(firebaseLibrary.version) - previousVersionString.value( - GmavenHelper(firebaseLibrary.groupId.get(), firebaseLibrary.artifactId.get()) - .getLatestReleasedVersion() - ) + previousVersionString.value(previousVersion) dependsOn("copyPreviousArtifacts") } diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java deleted file mode 100644 index 4da105f1115..00000000000 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.java +++ /dev/null @@ -1,195 +0,0 @@ -// 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.ImmutableSet; -import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension; -import java.io.File; -import java.util.Collections; -import java.util.Optional; -import java.util.Set; -import javax.inject.Inject; -import org.gradle.api.Action; -import org.gradle.api.Project; -import org.gradle.api.internal.provider.DefaultProvider; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.provider.Property; -import org.gradle.api.publish.maven.MavenPom; - -// TODO(b/270576405): rewrite in kotlin, and utilize conventions -public class FirebaseLibraryExtension { - - public final Project project; - public final LibraryType type; - /** Indicates whether the library has public javadoc. */ - public boolean publishJavadoc = true; - - /** Indicates whether release notes are published for the library. */ - public boolean publishReleaseNotes = true; - - /** Indicates whether sources are published alongside the library. */ - public boolean publishSources; - - /** - * Indicates the library is in a preview mode (alpha, beta, ...), and must publish with a tag - */ - public String previewMode = ""; - - /** Static analysis configuration. */ - public final FirebaseStaticAnalysis staticAnalysis; - - /** Firebase Test Lab configuration/ */ - public final FirebaseTestLabExtension testLab; - - public Property groupId; - public Property artifactId; - - String libraryGroupName; - - private Action customizePomAction = - pom -> { - pom.licenses( - licenses -> - licenses.license( - license -> { - license.getName().set("The Apache Software License, Version 2.0"); - license.getUrl().set("http://www.apache.org/licenses/LICENSE-2.0.txt"); - })); - pom.scm( - scm -> { - scm.getConnection() - .set("scm:git:https://github.com/firebase/firebase-android-sdk.git"); - scm.getUrl().set("https://github.com/firebase/firebase-android-sdk"); - }); - }; - - @Inject - public FirebaseLibraryExtension(Project project, LibraryType type) { - this.project = project; - this.type = type; - this.testLab = new FirebaseTestLabExtension(project.getObjects()); - this.artifactId = project.getObjects().property(String.class); - this.groupId = project.getObjects().property(String.class); - - if ("ktx".equals(project.getName()) && project.getParent() != null) { - artifactId.set(new DefaultProvider<>(() -> project.getParent().getName() + "-ktx")); - groupId.set(new DefaultProvider<>(() -> project.getParent().getGroup().toString())); - } else { - artifactId.set(new DefaultProvider<>(project::getName)); - groupId.set(new DefaultProvider<>(() -> project.getGroup().toString())); - } - this.staticAnalysis = initializeStaticAnalysis(project); - libraryGroupName = this.artifactId.get(); - } - - private FirebaseStaticAnalysis initializeStaticAnalysis(Project project) { - return new FirebaseStaticAnalysis( - projectsFromProperty(project, "firebase.checks.lintProjects")); - } - - private Set projectsFromProperty(Project project, String propertyName) { - if (!project.hasProperty(propertyName)) { - return Collections.emptySet(); - } - return ImmutableSet.copyOf(project.property(propertyName).toString().split(",", -1)); - } - - /** Configure Firebase Test Lab. */ - public void testLab(Action action) { - action.execute(testLab); - } - - /** - * Register to be released alongside another Firebase Library project. - * - *

This will force the released version of the current project to match the one it's released - * with. - */ - public void libraryGroup(String libraryGroupName) { - this.libraryGroupName = libraryGroupName; - } - - /** Provides a hook to customize pom generation. */ - public void customizePom(Action action) { - customizePomAction = action; - } - - public void applyPomCustomization(MavenPom pom) { - if (customizePomAction != null) { - customizePomAction.execute(pom); - } - } - - public void staticAnalysis(Action action) { - action.execute(staticAnalysis); - } - - public String getVersion() { - return project.getVersion().toString(); - } - - public Optional getLatestReleasedVersion() { - if (project.hasProperty("latestReleasedVersion")) { - return Optional.of(project.property("latestReleasedVersion").toString()); - } - return Optional.empty(); - } - - public String getMavenName() { - return groupId.get() + ":" + artifactId.get(); - } - - public String getPath() { - return project.getPath(); - } - - public Set getSrcDirs() { - switch (type) { - case ANDROID: - return project - .getExtensions() - .getByType(LibraryExtension.class) - .getSourceSets() - .getByName("main") - .getJava() - .getSrcDirs(); - case JAVA: - return project - .getConvention() - .getPlugin(JavaPluginConvention.class) - .getSourceSets() - .getByName("main") - .getJava() - .getSrcDirs(); - default: - throw new IllegalStateException("Unsupported project type: " + type); - } - } - - public String getRuntimeClasspath() { - if (type.equals(LibraryType.ANDROID)) { - return "releaseRuntimeClasspath"; - } - return "runtimeClasspath"; - } - - @Override - public String toString() { - return String.format( - "FirebaseLibraryExtension{name=\"%s:%s\", project=\"%s\", type=\"%s\"}", - groupId.get(), artifactId.get(), getPath(), type); - } -} diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.kt new file mode 100644 index 00000000000..9177a47c4c3 --- /dev/null +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.kt @@ -0,0 +1,138 @@ +package com.google.firebase.gradle.plugins + +import com.android.build.gradle.LibraryExtension +import com.google.firebase.gradle.plugins.ci.device.FirebaseTestLabExtension +import org.gradle.api.Action +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider +import org.gradle.api.publish.maven.MavenPom +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.invoke +import java.io.File +import javax.inject.Inject + +// TODO(b/XXXX): Identify proper property usage +// TODO(b/XXXX): Ensure correct downstream property usage +// TODO(b/XXXX): Move functions and extra variables to proper location +abstract class FirebaseLibraryExtension { + abstract val project: Property + abstract val type: Property + + abstract val publishJavadoc: Property + abstract val publishReleaseNotes: Property + abstract val publishSources: Property + + abstract val previewMode: Property + + abstract val groupId: Property + abstract val artifactId: Property + + abstract val libraryGroup: Property + + fun commonConfiguration(target: Project, libraryType: LibraryType) { + project.convention(target) + type.convention(libraryType) + publishJavadoc.convention(true) + publishReleaseNotes.convention(true) + publishSources.convention(true) + previewMode.convention("") + target.extensions.create("testLab", target.objects) + + if(target.name === "ktx" && target.parent !== null) { + artifactId.convention("${target.parent?.name}-ktx") + groupId.convention(target.parent?.group?.toString()) + } else { + artifactId.convention(target.name) + groupId.convention(target.group.toString()) + } + + val lintProjects = target.provideProperty("firebase.checks.lintProjects").map { + it.orEmpty().split(",") + } + + target.extensions.create("staticAnalysis", lintProjects.get().toSet()) + libraryGroup.convention(artifactId) + } + + fun testLab(action: Action) { + project.get().extensions.configure { + action.execute(this) + } + } + + fun customizePom(pom: MavenPom) { + pom.licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + pom.scm { + connection.set("scm:git:https://github.com/firebase/firebase-android-sdk.git") + url.set("https://github.com/firebase/firebase-android-sdk") + } + } + + fun libraryGroup(name: String) { + libraryGroup.set(name) + } + + val version: Provider + get() = project.map { it.version.toString() } + + val latestReleasedVersion: Provider + get() = project.flatMap { + it.provideProperty("latestReleasedVersion") + } + + val mavenName: Provider + get() = groupId.flatMap { groupId -> + artifactId.map { artifactId -> + "$groupId:$artifactId" + } + } + + val path: Provider + get() = project.map { it.path } + + val srcDirs: Provider> + get() = project.flatMap { project -> + type.map { + when(it) { + LibraryType.ANDROID -> + project.extensions.getByType() + .sourceSets + .getByName("main") + .java + .srcDirs + LibraryType.JAVA -> + project.extensions.getByType() + .sourceSets + .getByName("main") + .java + .srcDirs + null -> throw IllegalStateException("Project type was unset.") + } + } + } + + val runtimeClasspath: Provider + get() = type.map { + if (it === LibraryType.ANDROID) "releaseRuntimeClasspath" else "runtimeClasspath" + } + + val staticAnalysis: FirebaseStaticAnalysis + get() = project.get().extensions.getByType() + + val testLab: FirebaseTestLabExtension + get() = project.get().extensions.getByType() + + override fun toString(): String { + return """FirebaseLibraryExtension{name="${mavenName.get()}", project="${project.get()}", type="${type.get()}" """ + } +} \ No newline at end of file diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.kt index ef3e05e5506..9a4e65cd840 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.kt @@ -60,7 +60,7 @@ class FirebaseLibraryPlugin : BaseFirebaseLibraryPlugin() { private fun setupAndroidLibraryExtension(project: Project) { val firebaseLibrary = - project.extensions.create("firebaseLibrary", project, ANDROID) + project.extensions.create("firebaseLibrary",) val android = project.extensions.getByType() android.compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -84,6 +84,7 @@ class FirebaseLibraryPlugin : BaseFirebaseLibraryPlugin() { it.systemProperty("javax.net.ssl.trustStoreType", "JKS") } + firebaseLibrary.commonConfiguration(project, ANDROID) setupApiInformationAnalysis(project, android) android.testServer(FirebaseTestServer(project, firebaseLibrary.testLab, android)) setupStaticAnalysis(project, firebaseLibrary) @@ -94,10 +95,10 @@ class FirebaseLibraryPlugin : BaseFirebaseLibraryPlugin() { private fun setupVersionCheckTasks(project: Project, firebaseLibrary: FirebaseLibraryExtension) { project.tasks.register("gmavenVersionCheck") { - groupId.value(firebaseLibrary.groupId.get()) - artifactId.value(firebaseLibrary.artifactId.get()) + groupId.value(firebaseLibrary.groupId) + artifactId.value(firebaseLibrary.artifactId) version.value(firebaseLibrary.version) - latestReleasedVersion.value(firebaseLibrary.latestReleasedVersion.orElseGet { "" }) + latestReleasedVersion.value(firebaseLibrary.latestReleasedVersion.orElse("")) } project.mkdir("semver") project.mkdir("semver/previous-version") @@ -105,16 +106,17 @@ class FirebaseLibraryPlugin : BaseFirebaseLibraryPlugin() { dependsOn("bundleReleaseAar") project.file("semver/previous.aar").delete() - groupId.value(firebaseLibrary.groupId.get()) - artifactId.value(firebaseLibrary.artifactId.get()) + groupId.value(firebaseLibrary.groupId) + artifactId.value(firebaseLibrary.artifactId) aarAndroidFile.value(true) filePath.value(project.file("semver/previous.aar").absolutePath) } - val artifact = firebaseLibrary.artifactId.get() - val releaseAar = if (artifact.contains("-ktx")) "ktx-release.aar" else "${artifact}-release.aar" project.tasks.register("extractCurrentClasses") { dependsOn("bundleReleaseAar") + val artifact = firebaseLibrary.artifactId.get() + val releaseAar = if (artifact.contains("-ktx")) "ktx-release.aar" else "$artifact-release.aar" + from(project.zipTree("build/outputs/aar/${releaseAar}")) into(project.file("semver/current-version")) } diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseProprietaryLibraryPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseProprietaryLibraryPlugin.kt deleted file mode 100644 index c63eb056d43..00000000000 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseProprietaryLibraryPlugin.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2021 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 org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.apply - -class FirebaseProprietaryLibraryPlugin : Plugin { - override fun apply(project: Project) { - project.apply(plugin = "firebase-library") - - val library = project.extensions.getByType(FirebaseLibraryExtension::class.java) - library.publishSources = false - library.customizePom { - licenses { - license { - name.set("Android Software Development Kit License") - url.set("https://developer.android.com/studio/terms.html") - } - } - } - } -} diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroups.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroups.kt index c06e7aaf95d..8c5711f2ae0 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroups.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroups.kt @@ -33,18 +33,18 @@ fun computeLibraryGroups(project: Project): Map>) { - for ((name, libraryGroup) in libraryGroups) { + for ((_, libraryGroup) in libraryGroups) { val maxVersion = libraryGroup.mapNotNull { it.moduleVersion }.maxOrNull()?.toString() ?: continue for (firebaseExtension in libraryGroup) { - if (ModuleVersion.fromStringOrNull(firebaseExtension.project.version.toString()) == null) { - firebaseExtension.project.version = maxVersion.toString() + if (ModuleVersion.fromStringOrNull(firebaseExtension.project.get().version.toString()) == null) { + firebaseExtension.project.get().version = maxVersion } } } @@ -68,8 +68,8 @@ fun expandWithLibraryGroup( libraryGroups: Map> ) = libraries - .flatMap { libraryGroups.getOrDefault(it.libraryGroupName, emptyList()) } + .flatMap { libraryGroups.getOrDefault(it.libraryGroup, emptyList()) } .distinctBy { it.artifactId.get() } val FirebaseLibraryExtension.moduleVersion: ModuleVersion? - get() = ModuleVersion.fromStringOrNull(version) + get() = ModuleVersion.fromStringOrNull(version.get()) diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt index 76144e74d0b..495793733b0 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/PublishingPlugin.kt @@ -80,7 +80,7 @@ abstract class PublishingPlugin : Plugin { val releaseMetadata = computeReleaseMetadata(project, allFirebaseLibraries, libraryGroups) val releasingFirebaseLibraries = releaseMetadata?.releasingLibraries.orEmpty() - val releasingProjects = releasingFirebaseLibraries.map { it.project } + val releasingProjects = releasingFirebaseLibraries.map { it.project.get() } val generateBom = registerGenerateBomTask(project) val validatePomForRelease = registerValidatePomForReleaseTask(project, releasingProjects) @@ -244,7 +244,7 @@ abstract class PublishingPlugin : Plugin { val libraryGroupsToRelease = inputProjects .flatMap { it.resolveProjectLevelDependencies() + it } - .map { it.libraryGroupName } + .map { it.libraryGroup.get() } val projectsToRelease = libraryGroups .filterKeys { it in libraryGroupsToRelease } @@ -264,7 +264,7 @@ abstract class PublishingPlugin : Plugin { return releaseConfigFile?.let { val releaseConfig = ReleaseConfig.fromFile(it) - val librariesToRelease = allFirebaseLibraries.filter { it.path in releaseConfig.libraries } + val librariesToRelease = allFirebaseLibraries.filter { it.path.get() in releaseConfig.libraries } val missingLibrariesToRelease = computeMissingLibrariesToRelease(librariesToRelease, libraryGroups) @@ -350,9 +350,9 @@ abstract class PublishingPlugin : Plugin { ) } for (releasingLibrary in releasinglibraries) { - if (!releasingLibrary.version.contains(releasingLibrary.previewMode)) { + if (!releasingLibrary.version.get().contains(releasingLibrary.previewMode.get())) { throw GradleException( - "You are releasing a ${releasingLibrary.previewMode} SDK (${releasingLibrary.artifactId.get()}) as ${releasingLibrary.version}!" + "You are releasing a ${releasingLibrary.previewMode.get()} SDK (${releasingLibrary.artifactId.get()}) as ${releasingLibrary.version.get()}!" ) } } @@ -425,7 +425,7 @@ abstract class PublishingPlugin : Plugin { ) = project.tasks.register(GENERATE_KOTLINDOC_FOR_RELEASE_TASK) { for (releasingLibrary in releasingLibraries) { - val kotlindocTask = releasingLibrary.project.tasks.named("kotlindoc") + val kotlindocTask = releasingLibrary.project.get().tasks.named("kotlindoc") dependsOn(kotlindocTask) @@ -560,7 +560,7 @@ abstract class PublishingPlugin : Plugin { project.tasks.register(PUBLISH_ALL_TO_BUILD_TASK) { for (firebaseLibrary in allFirebaseLibraries) { val publishTask = - firebaseLibrary.project.tasks.named("publishMavenAarPublicationToBuildDirRepository") + firebaseLibrary.project.get().tasks.named("publishMavenAarPublicationToBuildDirRepository") dependsOn(publishTask) } diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ReleaseGenerator.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ReleaseGenerator.kt index 0be620e52f7..690eacadbc4 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ReleaseGenerator.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ReleaseGenerator.kt @@ -197,8 +197,8 @@ abstract class ReleaseGenerator : DefaultTask() { .filter { checkDirChanges(repo, previousReleaseRef, currentReleaseRef, "${getRelativeDir(it)}/") } - .flatMap { libraryGroups.getOrDefault(it.firebaseLibrary.libraryGroupName, emptyList()) } - .map { it.path } + .flatMap { libraryGroups.getOrDefault(it.firebaseLibrary.libraryGroup.get(), emptyList()) } + .map { it.path.get() } .toSet() private fun getChangedChangelogs( @@ -217,9 +217,9 @@ abstract class ReleaseGenerator : DefaultTask() { ) } .flatMap { - libraryGroups.getOrDefault(it.firebaseLibrary.libraryGroupName, listOf(it.firebaseLibrary)) + libraryGroups.getOrDefault(it.firebaseLibrary.libraryGroup.get(), listOf(it.firebaseLibrary)) } - .map { it.project } + .map { it.project.get() } .toSet() private fun checkDirChanges( diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/UpdatePinnedDependenciesTask.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/UpdatePinnedDependenciesTask.kt index db068592c6a..3c1fb3715ea 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/UpdatePinnedDependenciesTask.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/UpdatePinnedDependenciesTask.kt @@ -83,14 +83,14 @@ abstract class UpdatePinnedDependenciesTask : DefaultTask() { if (oldContent == updatedContent) throw RuntimeException( "Expected the following project level dependencies, but found none: " + - "${dependenciesToChange.joinToString("\n") { it.mavenName }}" + dependenciesToChange.joinToString("\n") { it.mavenName.get()} ) val diff = oldContent.diff(updatedContent) val changedLines = diff.mapNotNull { it.first ?: it.second } val (librariesCorrectlyChanged, linesChangedIncorrectly) = - dependenciesToChange.partition { lib -> changedLines.any { it.contains(lib.path) } } + dependenciesToChange.partition { lib -> changedLines.any { it.contains(lib.path.get()) } } val librariesNotChanged = dependenciesToChange - librariesCorrectlyChanged @@ -101,7 +101,7 @@ abstract class UpdatePinnedDependenciesTask : DefaultTask() { if (librariesNotChanged.isNotEmpty()) throw RuntimeException( - "The following libraries were not found, but should have been:\n ${librariesNotChanged.joinToString("\n") { it.mavenName }}" + "The following libraries were not found, but should have been:\n ${librariesNotChanged.joinToString("\n") { it.mavenName.get() }}" ) if (librariesCorrectlyChanged.size > dependenciesToChange.size) @@ -114,11 +114,11 @@ abstract class UpdatePinnedDependenciesTask : DefaultTask() { libraryGroups: Map> ) = with(project.firebaseLibrary) { - projectLevelDependencies - libraryGroups.getOrDefault(libraryGroupName, emptyList()) + projectLevelDependencies - libraryGroups.getOrDefault(libraryGroup.get(), emptyList()).toSet() } private val FirebaseLibraryExtension.projectLevelDependencies: List - get() = resolveProjectLevelDependencies().filterNot { it.path in DEPENDENCIES_TO_IGNORE } + get() = resolveProjectLevelDependencies().filterNot { it.path.get() in DEPENDENCIES_TO_IGNORE } private fun replaceProjectLevelDependencies( buildFileContent: List, @@ -126,10 +126,10 @@ abstract class UpdatePinnedDependenciesTask : DefaultTask() { ) = buildFileContent.replaceMatches(DEPENDENCY_REGEX) { val projectName = it.firstCapturedValue - val projectToChange = libraries.find { it.path == projectName } + val projectToChange = libraries.find { it.path.get() == projectName } val latestVersion = projectToChange?.latestVersion - latestVersion?.let { "\"${projectToChange.mavenName}:$latestVersion\"" } + latestVersion?.let { "\"${projectToChange.mavenName.get()}:$latestVersion\"" } } companion object { diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/Coverage.java b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/Coverage.java index 8a429bb88d6..fe0cf9262e7 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/Coverage.java +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/Coverage.java @@ -30,7 +30,7 @@ public final class Coverage { private Coverage() {} public static void apply(FirebaseLibraryExtension firebaseLibrary) { - Project project = firebaseLibrary.project; + Project project = firebaseLibrary.getProject().get(); project.apply(ImmutableMap.of("plugin", "jacoco")); File reportsDir = new File(project.getBuildDir(), "/reports/jacoco"); JacocoPluginExtension jacoco = project.getExtensions().getByType(JacocoPluginExtension.class); @@ -97,12 +97,12 @@ public static void apply(FirebaseLibraryExtension firebaseLibrary) { reports .getHtml() .setDestination( - new File(reportsDir, firebaseLibrary.artifactId.get() + "/html")); + new File(reportsDir, firebaseLibrary.getArtifactId().get() + "/html")); reports.getXml().getRequired().set(true); reports .getXml() .setDestination( - new File(reportsDir, firebaseLibrary.artifactId.get() + ".xml")); + new File(reportsDir, firebaseLibrary.getArtifactId().get() + ".xml")); }); task.getOutputs().upToDateWhen(t -> false); }); diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/SmokeTestsPlugin.java b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/SmokeTestsPlugin.java index 3556c1b62b9..c2928458106 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/SmokeTestsPlugin.java +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/SmokeTestsPlugin.java @@ -58,8 +58,8 @@ public void apply(Project project) { return; } - String groupId = firebaseLibrary.groupId.get(); - String artifactId = firebaseLibrary.artifactId.get(); + String groupId = firebaseLibrary.getGroupId().get(); + String artifactId = firebaseLibrary.getArtifactId().get(); String artifact = String.format("%s:%s:%s", groupId, artifactId, sub.getVersion()); allArtifacts.add(artifact); @@ -125,7 +125,7 @@ private static void getChangedProjectsLoop(Collection projects, Set affected = all.stream() .filter(it -> it instanceof ProjectDependency) diff --git a/firebase-firestore/firebase-firestore.gradle b/firebase-firestore/firebase-firestore.gradle index 84b5b2ce324..753d3e2ce12 100644 --- a/firebase-firestore/firebase-firestore.gradle +++ b/firebase-firestore/firebase-firestore.gradle @@ -23,8 +23,8 @@ firebaseLibrary { libraryGroup "firestore" publishSources = true testLab { - enabled = true - timeout = '45m' + enabled true + timeout '45m' } }