refactor(build): migrate to java-semver
This commit is contained in:
parent
e266534579
commit
93ee16df38
3 changed files with 13 additions and 13 deletions
|
@ -8,7 +8,7 @@ package app.passwordstore.gradle.versioning
|
|||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.android.build.api.variant.VariantOutputConfiguration
|
||||
import com.android.build.gradle.internal.plugins.AppPlugin
|
||||
import com.vdurmont.semver4j.Semver
|
||||
import com.github.zafarkhaja.semver.Version
|
||||
import java.util.Properties
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import org.gradle.api.Plugin
|
||||
|
@ -56,30 +56,30 @@ class VersioningPlugin : Plugin<Project> {
|
|||
}
|
||||
}
|
||||
}
|
||||
val version = Semver(versionName)
|
||||
val version = Version.parse(versionName)
|
||||
tasks.register<VersioningTask>("clearPreRelease") {
|
||||
description = "Remove the pre-release suffix from the version"
|
||||
semverString.set(version.withClearedSuffix().toString())
|
||||
semverString.set(version.toStableVersion().toString())
|
||||
propertyFile.set(propFile)
|
||||
}
|
||||
tasks.register<VersioningTask>("bumpMajor") {
|
||||
description = "Increment the major version"
|
||||
semverString.set(version.withIncMajor().withClearedSuffix().toString())
|
||||
semverString.set(version.nextMajorVersion().toString())
|
||||
propertyFile.set(propFile)
|
||||
}
|
||||
tasks.register<VersioningTask>("bumpMinor") {
|
||||
description = "Increment the minor version"
|
||||
semverString.set(version.withIncMinor().withClearedSuffix().toString())
|
||||
semverString.set(version.nextMinorVersion().toString())
|
||||
propertyFile.set(propFile)
|
||||
}
|
||||
tasks.register<VersioningTask>("bumpPatch") {
|
||||
description = "Increment the patch version"
|
||||
semverString.set(version.withIncPatch().withClearedSuffix().toString())
|
||||
semverString.set(version.nextPatchVersion().toString())
|
||||
propertyFile.set(propFile)
|
||||
}
|
||||
tasks.register<VersioningTask>("bumpSnapshot") {
|
||||
description = "Increment the minor version and add the `SNAPSHOT` suffix"
|
||||
semverString.set(version.withIncMinor().withSuffix("SNAPSHOT").toString())
|
||||
semverString.set(version.nextMinorVersion("SNAPSHOT").toString())
|
||||
propertyFile.set(propFile)
|
||||
}
|
||||
afterEvaluate {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
package app.passwordstore.gradle.versioning
|
||||
|
||||
import com.vdurmont.semver4j.Semver
|
||||
import com.github.zafarkhaja.semver.Version
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.Property
|
||||
|
@ -21,11 +21,11 @@ abstract class VersioningTask : DefaultTask() {
|
|||
@get:OutputFile abstract val propertyFile: RegularFileProperty
|
||||
|
||||
/** Generate the Android 'versionCode' property */
|
||||
private fun Semver.androidCode(): Int {
|
||||
return major * 1_00_00 + minor * 1_00 + patch
|
||||
private fun Version.androidCode(): Long {
|
||||
return majorVersion() * 1_00_00 + minorVersion() * 1_00 + patchVersion()
|
||||
}
|
||||
|
||||
private fun Semver.toPropFileText(): String {
|
||||
private fun Version.toPropFileText(): String {
|
||||
val newVersionCode = androidCode()
|
||||
val newVersionName = toString()
|
||||
return buildString {
|
||||
|
@ -45,6 +45,6 @@ abstract class VersioningTask : DefaultTask() {
|
|||
|
||||
@TaskAction
|
||||
fun execute() {
|
||||
propertyFile.get().asFile.writeText(Semver(semverString.get()).toPropFileText())
|
||||
propertyFile.get().asFile.writeText(Version.parse(semverString.get()).toPropFileText())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ build-moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
|
|||
build-moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
|
||||
build-okhttp = "com.squareup.okhttp3:okhttp:4.12.0"
|
||||
build-r8 = "com.android.tools:r8:8.3.37"
|
||||
build-semver = "com.vdurmont:semver4j:3.1.0"
|
||||
build-semver = "com.github.zafarkhaja:java-semver:0.10.2"
|
||||
build-sentry = "io.sentry.android.gradle:io.sentry.android.gradle.gradle.plugin:4.3.1"
|
||||
compose-bom = "androidx.compose:compose-bom:2024.03.00"
|
||||
compose-foundation-core = { module = "androidx.compose.foundation:foundation" }
|
||||
|
|
Loading…
Reference in a new issue