Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

package com.google.firebase.gradle.plugins.ci

import com.google.firebase.gradle.plugins.FirebaseLibraryExtension
import com.google.firebase.gradle.plugins.firebaseLibraryOrNull
import com.google.gson.Gson
import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
import org.gradle.kotlin.dsl.findByType

abstract class ChangedModulesTask : DefaultTask() {
@get:Input
Expand All @@ -48,36 +48,47 @@ abstract class ChangedModulesTask : DefaultTask() {

@TaskAction
fun execute() {
val projects =
AffectedProjectFinder(project, changedGitPaths.toSet(), listOf())
.find()
.filter {
val ext = it.extensions.findByType(FirebaseLibraryExtension::class.java)
!onlyFirebaseSDKs || it.extensions.findByType<FirebaseLibraryExtension>() != null
}
.map { it.path }
.toSet()

val result = project.rootProject.subprojects.associate { it.path to mutableSetOf<String>() }
project.rootProject.subprojects.forEach { p ->
p.configurations.forEach { c ->
c.dependencies.filterIsInstance<ProjectDependency>().forEach {
if (
!onlyFirebaseSDKs ||
it.dependencyProject.extensions.findByType<FirebaseLibraryExtension>() != null
) {
if (!onlyFirebaseSDKs || p.extensions.findByType<FirebaseLibraryExtension>() != null) {
result[it.dependencyProject.path]?.add(p.path)
}
val changedProjects = findChangedProjects()

val affectedProjects = findProjectsThatDependOnThese(changedProjects)

val outputProjects = (changedProjects + affectedProjects).toSet()

val projectPaths = outputProjects.map { it.path }

println(projectPaths.joinToString("\n"))

outputFile.writeText(Gson().toJson(projectPaths))
}

private fun findChangedProjects(): List<Project> {
val projectFinder = AffectedProjectFinder(project, changedGitPaths.toSet(), emptyList())
val allChangedProjects = projectFinder.find()

return allChangedProjects.filter { it.matchesOurFilter() }
}

private fun findProjectsThatDependOnThese(projects: List<Project>): List<Project> {
val dependentProjects =
project.rootProject.subprojects.filter {
it.configurations.any {
it.dependencies.filterIsInstance<ProjectDependency>().any {
projects.contains(it.dependencyProject)
}
}
}
}
val affectedProjects =
result
.flatMap { (key, value) -> if (projects.contains(key)) setOf(key) + value else setOf() }
.toSet()

outputFile.writeText(Gson().toJson(affectedProjects))
return dependentProjects.filter { it.matchesOurFilter() }
}

private fun Project.matchesOurFilter(): Boolean {
if (EXCLUDED_PROJECTS.contains(project.parent?.name)) return false
if (onlyFirebaseSDKs && firebaseLibraryOrNull == null) return false

return true
}

companion object {
val EXCLUDED_PROJECTS = listOf("protolite-well-known-types")
}
}
2 changes: 1 addition & 1 deletion firebase-firestore/firebase-firestore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ tasks.withType(Test) {
dependencies {
javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6'

api project(':protolite-well-known-types')
api "com.google.firebase:protolite-well-known-types:18.0.0"
api 'com.google.android.gms:play-services-tasks:18.0.1'
api 'com.google.firebase:firebase-annotations:16.2.0'
api 'com.google.firebase:firebase-appcheck-interop:17.0.0'
Expand Down
2 changes: 1 addition & 1 deletion firebase-inappmessaging/firebase-inappmessaging.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ dependencies {
exclude group: "javax.inject", module: "javax.inject"
}

api project(':protolite-well-known-types')
api "com.google.firebase:protolite-well-known-types:18.0.0"
api 'com.google.android.gms:play-services-tasks:18.0.1'
api('com.google.firebase:firebase-abt:21.1.1') {
exclude group: 'com.google.firebase', module: 'firebase-common'
Expand Down
2 changes: 1 addition & 1 deletion protolite-well-known-types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Unreleased

* [fixed] Fixed an issue that caused protolite to break when used alongside protolite `4.27.0`.

This file was deleted.

4 changes: 1 addition & 3 deletions protolite-well-known-types/protolite-well-known-types.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ protobuf {
}
generateProtoTasks {
all().each { task ->

task.addIncludeDir(files('fix-javalite/proto'))

task.builtins {
java {
option "lite"
Expand Down Expand Up @@ -68,5 +65,6 @@ dependencies {
exclude group: "com.google.protobuf", module: "protobuf-java"
}

// TODO(b/343482773): Migrate to 4.27+
implementation "com.google.protobuf:protobuf-javalite:$javaliteVersion"
}
Loading