Skip to content
Merged
Show file tree
Hide file tree
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 @@ -195,7 +195,7 @@ abstract class GenerateTutorialBundleTask : DefaultTask() {
} else {
logger.info("Fetching the latest version for an artifact: $fullArtifactName")

return gmaven.get().latestNonAlphaVersionOrNull(fullArtifactName)
return gmaven.get().latestStableVersionOrNull(fullArtifactName)
?: throw RuntimeException(
"An artifact required for the tutorial bundle is missing from gmaven: $fullArtifactName"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,36 @@ abstract class GMavenService : BuildService<BuildServiceParameters.None> {
controller.latestVersionOrNull(groupId, artifactId)

/**
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
* Gets the latest version with no qualifiers of the artifact that has been uploaded to GMaven, if
* any. *
*
* ```
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
* gmaven.latestStableVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
* ```
*
* @param groupId The group to search under.
* @param artifactId The artifact to search for.
* @return The latest released version as a string, or null if the artifact couldn't be found.
* @see latestVersion
*/
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String) =
controller.latestNonAlphaVersionOrNull(groupId, artifactId)
fun latestStableVersionOrNull(groupId: String, artifactId: String) =
controller.latestStableVersionOrNull(groupId, artifactId)

/**
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
* Gets the latest version with no qualifiers of the artifact that has been uploaded to GMaven, if
* any.
*
* ```
* gmaven.latestNonAlphaVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
* gmaven.latestStableVersionOrNull("com.google.firebase", "firebase-components") // "18.0.1"
* ```
*
* @param fullArtifactName The artifact to search for, represented as "groupId:artifactId".
* @return The latest released version as a string, or null if the artifact couldn't be found.
* @see latestVersion
*/
fun latestNonAlphaVersionOrNull(fullArtifactName: String): String? {
fun latestStableVersionOrNull(fullArtifactName: String): String? {
val (groupId, artifactId) = fullArtifactName.split(":")
return latestNonAlphaVersionOrNull(groupId, artifactId)
return latestStableVersionOrNull(groupId, artifactId)
}

/**
Expand Down Expand Up @@ -434,9 +436,9 @@ class GMavenServiceController(
return findFirebaseArtifact(groupId, artifactId)?.latestVersion
}

/** @see GMavenService.latestNonAlphaVersionOrNull */
fun latestNonAlphaVersionOrNull(groupId: String, artifactId: String): String? {
return findFirebaseArtifact(groupId, artifactId)?.latestNonAlphaVersion
/** @see GMavenService.latestStableVersionOrNull */
fun latestStableVersionOrNull(groupId: String, artifactId: String): String? {
return findFirebaseArtifact(groupId, artifactId)?.latestStableVersion
}

/** @see GMavenService.hasReleasedArtifact */
Expand Down Expand Up @@ -591,7 +593,7 @@ data class GroupIndexArtifact(
val artifactId: String,
val versions: List<String>,
val latestVersion: String = versions.last(),
val latestNonAlphaVersion: String? = versions.findLast { !it.contains("alpha") },
val latestStableVersion: String? = versions.findLast { !it.contains("-") },
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class GenerateTutorialBundleTests : FunSpec() {
@Test
fun `throws an error if an unreleased artifact is used`() {
shouldThrowSubstring("missing from gmaven", "com.google.firebase:firebase-auth") {
every { service.latestNonAlphaVersionOrNull(any()) } answers { null }
every { service.latestStableVersionOrNull(any()) } answers { null }

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

Expand Down Expand Up @@ -294,7 +294,7 @@ class GenerateTutorialBundleTests : FunSpec() {
"$groupId:$artifactId" to version
}
.onEach { entry ->
every { service.latestNonAlphaVersionOrNull(entry.key) } answers { entry.value }
every { service.latestStableVersionOrNull(entry.key) } answers { entry.value }
}
}

Expand Down
Loading