Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Perform gradle build
run: |
./gradlew firebasePublish -PpublishConfigFilePath=release.cfg -PpublishMode=RELEASE
./gradlew firebasePublish

- name: Generate release notes
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-head-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:

- name: Perform gradle build
run: |
./gradlew checkHeadDependencies -PpublishConfigFilePath=release.cfg -PpublishMode=RELEASE
./gradlew checkHeadDependencies
2 changes: 1 addition & 1 deletion .github/workflows/create_releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
base: 'releases/${{ inputs.name }}'
branch: 'releases/${{ inputs.name }}.release'
add-paths: release.cfg,release_report.md
add-paths: release.json,release_report.md
title: '${{ inputs.name}} release'
body: 'Auto-generated PR for release ${{ inputs.name}}'
commit-message: 'Create release config for ${{ inputs.name }}'
2 changes: 1 addition & 1 deletion .github/workflows/semver-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:

- name: Perform gradle build
run: |
./gradlew semverCheckForRelease -PpublishConfigFilePath=release.cfg -PpublishMode=RELEASE
./gradlew semverCheckForRelease
2 changes: 1 addition & 1 deletion .github/workflows/validate-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:

- name: Perform gradle build
run: |
./gradlew validatePomForRelease -PpublishConfigFilePath=release.cfg -PpublishMode=RELEASE
./gradlew validatePomForRelease
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin
import com.google.firebase.gradle.MultiProjectReleasePlugin

buildscript {
// TODO: remove once all sdks have migrated to version catalog
ext.kotlinVersion = libs.versions.kotlin.get()
Expand Down Expand Up @@ -58,11 +55,10 @@ ext {
protobufJavaUtilVersion = libs.versions.protobufjavautil.get()
}

apply plugin: com.google.firebase.gradle.plugins.publish.PublishingPlugin
apply plugin: com.google.firebase.gradle.plugins.ci.ContinuousIntegrationPlugin
apply plugin: com.google.firebase.gradle.plugins.ci.SmokeTestsPlugin

apply plugin: MultiProjectReleasePlugin
apply plugin: com.google.firebase.gradle.plugins.PublishingPlugin

firebaseContinuousIntegration {
ignorePaths = [
Expand Down
4 changes: 3 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
plugins {
id("com.ncorti.ktfmt.gradle") version "0.11.0"
id("com.github.sherter.google-java-format") version "0.9"
kotlin("plugin.serialization") version "1.7.10"
`kotlin-dsl`
}

Expand Down Expand Up @@ -67,6 +68,7 @@ dependencies {

implementation("org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r")

implementation(libs.kotlinx.serialization.json)
implementation("com.google.code.gson:gson:2.8.9")
implementation("com.android.tools.build:gradle:7.2.2")
implementation("com.android.tools.build:builder-test-api:7.2.2")
Expand All @@ -90,7 +92,7 @@ gradlePlugin {
}
register("publishingPlugin") {
id = "PublishingPlugin"
implementationClass = "com.google.firebase.gradle.plugins.publish.PublishingPlugin"
implementationClass = "com.google.firebase.gradle.plugins.PublishingPlugin"
}
register("firebaseLibraryPlugin") {
id = "firebase-library"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,45 @@ import org.gradle.api.provider.ListProperty
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

/**
* Validates that all project level dependencies are in the release.
*
* Any releasing library that has a project level dependency on another library invokes the release
* of said dependent libary. This is checked via the [artifactId]
* [FirebaseLibraryExtension.artifactId], so that the check is version agnostic.
*
* @throws GradleException if any project level dependencies are found that are not included in the
* release
*/
abstract class CheckHeadDependencies : DefaultTask() {
@get:Input abstract val projectsToPublish: ListProperty<FirebaseLibraryExtension>

@get:Input abstract val allFirebaseProjects: ListProperty<String>

@TaskAction
fun run() {
val projectsReleasing: Set<String> = projectsToPublish.get().map { it.artifactId.get() }.toSet()
val projectsReleasing = computeProjectsReleasing()

val errors =
projectsToPublish
.get()
.associate {
it.artifactId.get() to
it
.projectDependenciesByName()
.intersect(allFirebaseProjects.get())
.subtract(projectsReleasing)
.subtract(DEPENDENCIES_TO_IGNORE)
}
.associate { it.artifactId.get() to it.projectLevelDepsAsArtifactIds() - projectsReleasing }
.filterValues { it.isNotEmpty() }
.map { "${it.key} requires: ${it.value.joinToString(", ") }" }

if (errors.isNotEmpty()) {
throw GradleException(
"Project-level dependency errors found. Please update the release config.\n${
errors.joinToString(
"\n"
)
}"
"Project-level dependency errors found. Please update the release config.\n" +
"${errors.joinToString("\n")}"
)
}
}

private fun FirebaseLibraryExtension.projectDependenciesByName() =
private fun FirebaseLibraryExtension.projectLevelDepsAsArtifactIds() =
resolveProjectLevelDependencies().map { it.artifactId.get() }

private fun computeProjectsReleasing() =
projectsToPublish.get().map { it.artifactId.get() } + DEPENDENCIES_TO_IGNORE

companion object {
val DEPENDENCIES_TO_IGNORE: List<String> = listOf("protolite-well-known-types")
val DEPENDENCIES_TO_IGNORE = listOf("protolite-well-known-types")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ abstract class DackkaPlugin : Plugin<Project> {

kotlinDoc.configure {
dependsOn(generateDocumentation, firesiteTransform, copyDocsToCommonDirectory)

outputs.dir(copyDocsToCommonDirectory.map { it.destinationDir })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
import org.w3c.dom.Document

/** TODO(b/279466888) - Make GmavenHelper testable */
class GmavenHelper(val groupId: String, val artifactId: String) {
val GMAVEN_ROOT = "https://dl.google.com/dl/android/maven2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.firebase.gradle.plugins

import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.attributes.Attribute
Expand All @@ -24,6 +25,7 @@ import org.gradle.kotlin.dsl.apply
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkQueue
import org.jetbrains.kotlin.gradle.utils.provider

/**
* Creates a file at the buildDir for the given [Project].
Expand All @@ -45,6 +47,25 @@ fun Project.fileFromBuildDir(path: String) = file("$buildDir/$path")
*/
fun Provider<File>.childFile(path: String) = map { File("${it.path}/$path") }

/**
* Returns a new [File] under the given sub directory.
*
* Syntax sugar for:
* ```
* File("$path/$childPath")
* ```
*/
fun File.childFile(childPath: String) = File("$path/$childPath")

/**
* Provides a temporary file for use during the task.
*
* Creates a file under the [temporaryDir][DefaultTask.getTemporaryDir] of the task, and should be
* preferred to defining an explicit [File]. This will allow Gradle to make better optimizations on
* our part, and helps us avoid edge-case scenarios like conflicting file names.
*/
fun DefaultTask.tempFile(path: String) = provider { temporaryDir.childFile(path) }

/**
* Returns a list of children files, or an empty list if this [File] doesn't exist or doesn't have
* any children.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.FileCollection
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.getByType

/** Checks if the project has any of the common Android specific plugins. */
Expand Down Expand Up @@ -74,6 +75,17 @@ val Project.dackkaConfig: Configuration
val Project.firebaseLibrary: FirebaseLibraryExtension
get() = extensions.getByType<FirebaseLibraryExtension>()

/**
* The [FirebaseLibraryExtension] for this [Project], or null if not found.
*
* Syntax sugar for:
* ```kotlin
* extensions.findByType<FirebaseLibraryExtension>()
* ```
*/
val Project.firebaseLibraryOrNull: FirebaseLibraryExtension?
get() = extensions.findByType<FirebaseLibraryExtension>()

/**
* Hacky-check to see if the module is a ktx variant.
*
Expand All @@ -84,6 +96,21 @@ val Project.firebaseLibrary: FirebaseLibraryExtension
val Project.isKTXLibary: Boolean
get() = firebaseLibrary.artifactId.get().endsWith("-ktx")

/**
* Provides a project property as the specified type, or null otherwise.
*
* Utilizing a safe cast, an attempt is made to cast the project property (if found) to the receiver
* type. Should this cast fail, the resulting value will be null.
*
* Keep in mind that is provided lazily via a [Provider], so evalutation does not occur until the
* value is needed.
*
* @param property the name of the property to look for
*/
inline fun <reified T> Project.provideProperty(property: String) = provider {
findProperty(property) as? T
}

/** Fetches the jars of dependencies associated with this configuration through an artifact view. */
val Configuration.jars: FileCollection
get() =
Expand Down
Loading