Skip to content

add new check in validateProjectsToPublishTask #5204

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
Jul 27, 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 @@ -14,6 +14,7 @@

package com.google.firebase.gradle.plugins

import com.google.common.collect.Sets
import com.google.firebase.gradle.bomgenerator.BomGeneratorTask
import com.google.firebase.gradle.plugins.PublishingPlugin.Companion.BUILD_BOM_ZIP_TASK
import com.google.firebase.gradle.plugins.PublishingPlugin.Companion.BUILD_KOTLINDOC_ZIP_TASK
Expand Down Expand Up @@ -79,7 +80,7 @@ abstract class PublishingPlugin : Plugin<Project> {
val checkHeadDependencies =
registerCheckHeadDependenciesTask(project, releasingFirebaseLibraries)
val validateProjectsToPublish =
registerValidateProjectsToPublishTask(project, releasingProjects)
registerValidateProjectsToPublishTask(project, releasingFirebaseLibraries)
val publishReleasingLibrariesToBuildDir =
registerPublishReleasingLibrariesToBuildDirTask(project, releasingProjects)
val generateKotlindocsForRelease =
Expand Down Expand Up @@ -275,17 +276,26 @@ abstract class PublishingPlugin : Plugin<Project> {
// TODO(b/280320915): Remove doLast when Gradle + IDEA fix task configuration avoidance bug
private fun registerValidateProjectsToPublishTask(
project: Project,
releasingProjects: List<Project>
releasinglibraries: List<FirebaseLibraryExtension>
) =
project.tasks.register(VALIDATE_PROJECTS_TO_PUBLISH_TASK) {
doLast {
if (releasingProjects.isEmpty()) {
if (releasinglibraries.isEmpty()) {
throw GradleException(
"No projects to release. " +
"Ensure you've specified the projectsToPublish parameter, " +
"or have a valid $RELEASE_CONFIG_FILE file at the root directory."
)
}
val libraryGroupProjects =
releasinglibraries.flatMap { it.projectsToRelease }.filterNotNull().toSet()
val releasingProjects = releasinglibraries.mapNotNull { it.project }.toSet()
if (!libraryGroupProjects.equals(releasingProjects)) {
throw GradleException(
"Some libraries in library groups are not in the release: " +
Sets.difference(libraryGroupProjects, releasingProjects).map { it.displayName }
)
}
}
}

Expand Down