Skip to content

Improve CheckHeadDependencies check #4863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2023
Merged
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 @@ -29,24 +29,39 @@ abstract class CheckHeadDependencies : DefaultTask() {
@TaskAction
fun run() {
val projectsReleasing: Set<String> = projectsToPublish.get().map { it.artifactId.get() }.toSet()
val projectsToRelease =
val errors =
projectsToPublish
.get()
.flatMap {
it.project.configurations
.getByName(it.runtimeClasspath)
.allDependencies
.filter { it is ProjectDependency }
.map { it.name }
.toSet()
.associate {
it.artifactId.get() to
it
.projectDependenciesByName()
.intersect(allFirebaseProjects.get())
.subtract(projectsReleasing)
.subtract(DEPENDENCIES_TO_IGNORE)
}
.intersect(allFirebaseProjects.get())
.subtract(projectsReleasing)
.filterValues { it.isNotEmpty() }
.map { "${it.key} requires: ${it.value.joinToString(", ") }" }

if (projectsToRelease.isNotEmpty()) {
if (errors.isNotEmpty()) {
throw GradleException(
"Following Sdks have to release as well. Please update the release config.\n${projectsToRelease.joinToString("\n")}"
"Project-level dependency errors found. Please update the release config.\n${
errors.joinToString(
"\n"
)
}"
)
}
}

fun FirebaseLibraryExtension.projectDependenciesByName(): List<String> =
project.configurations
.getByName(runtimeClasspath)
.allDependencies
.filter { it is ProjectDependency }
.map { it.name }

companion object {
val DEPENDENCIES_TO_IGNORE: List<String> = listOf("protolite-well-known-types")
}
}