Skip to content
Draft
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 All @@ -206,10 +206,6 @@ abstract class GenerateTutorialBundleTask : DefaultTask() {
val (name, alias, extra) = mappings[fullArtifactName]!!

val version = versionString(fullArtifactName)
if (version.lowercase().contains("-alpha")) {
logger.info("Ignoring alpha version of $fullArtifactName")
return "" // Alpha versions should not be included in the tutorial bundle
}

return multiLine("<!-- $name -->", "<!ENTITY $alias \"$fullArtifactName:${version}\">", extra)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,41 @@ abstract class GMavenService : BuildService<BuildServiceParameters.None> {
return latestNonAlphaVersionOrNull(groupId, artifactId)
}

/**
* Gets the latest stable version of the artifact that has been uploaded to GMaven, if any.
*
* Stable versions do not include alpha or beta versions.
*
* ```
* 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 latestStableVersionOrNull(groupId: String, artifactId: String) =
controller.latestStableVersionOrNull(groupId, artifactId)

/**
* Gets the latest stable version of the artifact that has been uploaded to GMaven, if any.
*
* Stable versions do not include alpha or beta versions.
*
* ```
* 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 latestStableVersionOrNull(fullArtifactName: String): String? {
val (groupId, artifactId) = fullArtifactName.split(":")
return latestStableVersionOrNull(groupId, artifactId)
}

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

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

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

/**
Expand Down
Loading