Skip to content

Commit e6d2cf9

Browse files
authored
Merge branch 'main' into davidmotson.outpaint_flexibility
2 parents b7e4ceb + 89a59bf commit e6d2cf9

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

plugins/src/main/java/com/google/firebase/gradle/bomgenerator/GenerateTutorialBundleTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ abstract class GenerateTutorialBundleTask : DefaultTask() {
195195
} else {
196196
logger.info("Fetching the latest version for an artifact: $fullArtifactName")
197197

198-
return gmaven.get().latestVersionOrNull(fullArtifactName)
198+
return gmaven.get().latestNonAlphaVersionOrNull(fullArtifactName)
199199
?: throw RuntimeException(
200200
"An artifact required for the tutorial bundle is missing from gmaven: $fullArtifactName"
201201
)

plugins/src/main/java/com/google/firebase/gradle/plugins/services/GmavenService.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,37 @@ abstract class GMavenService : BuildService<BuildServiceParameters.None> {
150150
fun latestVersionOrNull(groupId: String, artifactId: String) =
151151
controller.latestVersionOrNull(groupId, artifactId)
152152

153+
/**
154+
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
155+
*
156+
* ```
157+
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
158+
* ```
159+
*
160+
* @param groupId The group to search under.
161+
* @param artifactId The artifact to search for.
162+
* @return The latest released version as a string, or null if the artifact couldn't be found.
163+
* @see latestVersion
164+
*/
165+
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String) =
166+
controller.latestNonAlphaVersionOrNull(groupId, artifactId)
167+
168+
/**
169+
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
170+
*
171+
* ```
172+
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
173+
* ```
174+
*
175+
* @param fullArtifactName The artifact to search for, represented as "groupId:artifactId".
176+
* @return The latest released version as a string, or null if the artifact couldn't be found.
177+
* @see latestVersion
178+
*/
179+
fun latestNonAlphaVersionOrNull(fullArtifactName: String): String? {
180+
val (groupId, artifactId) = fullArtifactName.split(":")
181+
return latestNonAlphaVersionOrNull(groupId, artifactId)
182+
}
183+
153184
/**
154185
* Gets the latest version of the artifact that has been uploaded to GMaven, if any.
155186
*
@@ -403,6 +434,11 @@ class GMavenServiceController(
403434
return findFirebaseArtifact(groupId, artifactId)?.latestVersion
404435
}
405436

437+
/** @see GMavenService.latestNonAlphaVersionOrNull */
438+
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String): String? {
439+
return findFirebaseArtifact(groupId, artifactId)?.latestNonAlphaVersion
440+
}
441+
406442
/** @see GMavenService.hasReleasedArtifact */
407443
fun hasReleasedArtifact(groupId: String, artifactId: String): Boolean {
408444
return findFirebaseArtifact(groupId, artifactId) !== null
@@ -555,6 +591,7 @@ data class GroupIndexArtifact(
555591
val artifactId: String,
556592
val versions: List<String>,
557593
val latestVersion: String = versions.last(),
594+
val latestNonAlphaVersion: String? = versions.findLast { !it.contains("alpha") },
558595
) {
559596

560597
/**

plugins/src/test/kotlin/com/google/firebase/gradle/plugins/GenerateTutorialBundleTests.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class GenerateTutorialBundleTests : FunSpec() {
242242
@Test
243243
fun `throws an error if an unreleased artifact is used`() {
244244
shouldThrowSubstring("missing from gmaven", "com.google.firebase:firebase-auth") {
245-
every { service.latestVersionOrNull(any()) } answers { null }
245+
every { service.latestNonAlphaVersionOrNull(any()) } answers { null }
246246

247247
val task = makeTask { firebaseArtifacts.set(listOf("com.google.firebase:firebase-auth")) }
248248

@@ -293,7 +293,9 @@ class GenerateTutorialBundleTests : FunSpec() {
293293
val (groupId, artifactId, version) = it.split(":")
294294
"$groupId:$artifactId" to version
295295
}
296-
.onEach { entry -> every { service.latestVersionOrNull(entry.key) } answers { entry.value } }
296+
.onEach { entry ->
297+
every { service.latestNonAlphaVersionOrNull(entry.key) } answers { entry.value }
298+
}
297299
}
298300

299301
private fun makeTutorial(

0 commit comments

Comments
 (0)