Skip to content

Commit e4369ab

Browse files
davidmotsonDavid Motsonashvili
andauthored
replace latestNonAlphaVersion with latestStableVersion (firebase#7565)
* this will filter all non-stable versions out of the BoM, not just alpha and beta --------- Co-authored-by: David Motsonashvili <[email protected]>
1 parent 964dccc commit e4369ab

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
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().latestNonAlphaVersionOrNull(fullArtifactName)
198+
return gmaven.get().latestStableVersionOrNull(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: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,36 @@ abstract class GMavenService : BuildService<BuildServiceParameters.None> {
151151
controller.latestVersionOrNull(groupId, artifactId)
152152

153153
/**
154-
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
154+
* Gets the latest version with no qualifiers of the artifact that has been uploaded to GMaven, if
155+
* any. *
155156
*
156157
* ```
157-
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
158+
* gmaven.latestStableVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
158159
* ```
159160
*
160161
* @param groupId The group to search under.
161162
* @param artifactId The artifact to search for.
162163
* @return The latest released version as a string, or null if the artifact couldn't be found.
163164
* @see latestVersion
164165
*/
165-
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String) =
166-
controller.latestNonAlphaVersionOrNull(groupId, artifactId)
166+
fun latestStableVersionOrNull(groupId: String, artifactId: String) =
167+
controller.latestStableVersionOrNull(groupId, artifactId)
167168

168169
/**
169-
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
170+
* Gets the latest version with no qualifiers of the artifact that has been uploaded to GMaven, if
171+
* any.
170172
*
171173
* ```
172-
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
174+
* gmaven.latestStableVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
173175
* ```
174176
*
175177
* @param fullArtifactName The artifact to search for, represented as "groupId:artifactId".
176178
* @return The latest released version as a string, or null if the artifact couldn't be found.
177179
* @see latestVersion
178180
*/
179-
fun latestNonAlphaVersionOrNull(fullArtifactName: String): String? {
181+
fun latestStableVersionOrNull(fullArtifactName: String): String? {
180182
val (groupId, artifactId) = fullArtifactName.split(":")
181-
return latestNonAlphaVersionOrNull(groupId, artifactId)
183+
return latestStableVersionOrNull(groupId, artifactId)
182184
}
183185

184186
/**
@@ -434,9 +436,9 @@ class GMavenServiceController(
434436
return findFirebaseArtifact(groupId, artifactId)?.latestVersion
435437
}
436438

437-
/** @see GMavenService.latestNonAlphaVersionOrNull */
438-
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String): String? {
439-
return findFirebaseArtifact(groupId, artifactId)?.latestNonAlphaVersion
439+
/** @see GMavenService.latestStableVersionOrNull */
440+
fun latestStableVersionOrNull(groupId: String, artifactId: String): String? {
441+
return findFirebaseArtifact(groupId, artifactId)?.latestStableVersion
440442
}
441443

442444
/** @see GMavenService.hasReleasedArtifact */
@@ -591,7 +593,7 @@ data class GroupIndexArtifact(
591593
val artifactId: String,
592594
val versions: List<String>,
593595
val latestVersion: String = versions.last(),
594-
val latestNonAlphaVersion: String? = versions.findLast { !it.contains("alpha") },
596+
val latestStableVersion: String? = versions.findLast { !it.contains("-") },
595597
) {
596598

597599
/**

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

Lines changed: 2 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.latestNonAlphaVersionOrNull(any()) } answers { null }
245+
every { service.latestStableVersionOrNull(any()) } answers { null }
246246

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

@@ -294,7 +294,7 @@ class GenerateTutorialBundleTests : FunSpec() {
294294
"$groupId:$artifactId" to version
295295
}
296296
.onEach { entry ->
297-
every { service.latestNonAlphaVersionOrNull(entry.key) } answers { entry.value }
297+
every { service.latestStableVersionOrNull(entry.key) } answers { entry.value }
298298
}
299299
}
300300

0 commit comments

Comments
 (0)