-
Notifications
You must be signed in to change notification settings - Fork 624
Restructure library group logic in buildSrc #5297
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f161754
Restructure library group logic in buildSrc
rlazo 4c3004b
Fix formatting
rlazo d4ff47e
Merge branch 'master' into rl.library.groups
rlazo 2681f4c
Address review comments
rlazo 58c4fd7
Add missing documentation
rlazo bcd55d3
Update tests for updatePinnedDependencies
rlazo 959bc2e
Merge branch 'master' into rl.library.groups
rlazo 3908bbe
Update ReleaseGenerator to use the provided libraryGroups
rlazo c0c1d69
Merge branch 'master' into rl.library.groups
rlazo 2a08a7e
Merge branch 'master' into rl.library.groups
rlazo 6c68174
Fix smoke test issues
rlazo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroupRegistrar.kt
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
buildSrc/src/main/java/com/google/firebase/gradle/plugins/LibraryGroups.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2023 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.GradleException | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* Returns a map of library group names to the list of libraries that belong to that group. | ||
* | ||
* Libraries, aka projects with `FirebaseLibraryExtension`, always belong to a library group. See | ||
* [FirebaseLibraryExtension] to know more about library group names. | ||
*/ | ||
fun computeLibraryGroups(project: Project): Map<String, List<FirebaseLibraryExtension>> { | ||
if (project != project.rootProject) { | ||
rlazo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw GradleException( | ||
"Error trying to generate library groups from non root project. " + | ||
"Computing library groups for non root projects can generate incomplete views." | ||
) | ||
} | ||
val libraryGroups = | ||
project.subprojects.mapNotNull { it.firebaseLibraryOrNull }.groupBy { it.libraryGroupName } | ||
|
||
return libraryGroups | ||
} | ||
|
||
fun fixLibraryGroupVersions(libraryGroups: Map<String, List<FirebaseLibraryExtension>>) { | ||
for ((name, libraryGroup) in libraryGroups) { | ||
val maxVersion = | ||
rlazo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
libraryGroup.mapNotNull { it.moduleVersion }.maxOrNull()?.toString() ?: continue | ||
for (firebaseExtension in libraryGroup) { | ||
if (ModuleVersion.fromStringOrNull(firebaseExtension.project.version.toString()) == null) { | ||
firebaseExtension.project.version = maxVersion.toString() | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns the list of libraries that should be transitively included in a release but are not. | ||
* | ||
* Based on [librariesToRelease], this function will find and return all libraries that belongs to | ||
* the same library group of a releasing library and are not included. | ||
*/ | ||
fun computeMissingLibrariesToRelease( | ||
librariesToRelease: List<FirebaseLibraryExtension>, | ||
libraryGroups: Map<String, List<FirebaseLibraryExtension>> | ||
): List<FirebaseLibraryExtension> = | ||
expandWithLibraryGroup(librariesToRelease, libraryGroups) - librariesToRelease | ||
|
||
/** Returns a list that includes [libraries] and all their library group members. */ | ||
fun expandWithLibraryGroup( | ||
libraries: List<FirebaseLibraryExtension>, | ||
libraryGroups: Map<String, List<FirebaseLibraryExtension>> | ||
) = | ||
libraries | ||
.flatMap { libraryGroups.getOrDefault(it.libraryGroupName, emptyList()) } | ||
.distinctBy { it.artifactId.get() } | ||
|
||
val FirebaseLibraryExtension.moduleVersion: ModuleVersion? | ||
get() = ModuleVersion.fromStringOrNull(version) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.