Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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().latestVersionOrNull(fullArtifactName)
return gmaven.get().latestNonAlphaVersionOrNull(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 @@ -150,6 +150,37 @@ abstract class GMavenService : BuildService<BuildServiceParameters.None> {
fun latestVersionOrNull(groupId: String, artifactId: String) =
controller.latestVersionOrNull(groupId, artifactId)

/**
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
*
* ```
* gmaven.latestNonAlphaVersionOrNull("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)

/**
* Gets the latest non-alpha version of the artifact that has been uploaded to GMaven, if any.
*
* ```
* gmaven.latestNonAlphaVersionOrNull("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? {
val (groupId, artifactId) = fullArtifactName.split(":")
return latestNonAlphaVersionOrNull(groupId, artifactId)
}

/**
* Gets the latest version of the artifact that has been uploaded to GMaven, if any.
*
Expand Down Expand Up @@ -403,6 +434,11 @@ class GMavenServiceController(
return findFirebaseArtifact(groupId, artifactId)?.latestVersion
}

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

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

/**
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.latestVersionOrNull(any()) } answers { null }
every { service.latestNonAlphaVersionOrNull(any()) } answers { null }

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

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

private fun makeTutorial(
Expand Down
Loading