diff options
Diffstat (limited to 'buildSrc/src/main/java')
-rw-r--r-- | buildSrc/src/main/java/BaseProjectConfig.kt | 4 | ||||
-rw-r--r-- | buildSrc/src/main/java/Dependencies.kt | 4 | ||||
-rw-r--r-- | buildSrc/src/main/java/VersioningPlugin.kt | 36 |
3 files changed, 20 insertions, 24 deletions
diff --git a/buildSrc/src/main/java/BaseProjectConfig.kt b/buildSrc/src/main/java/BaseProjectConfig.kt index a6384047..d1944888 100644 --- a/buildSrc/src/main/java/BaseProjectConfig.kt +++ b/buildSrc/src/main/java/BaseProjectConfig.kt @@ -25,9 +25,9 @@ internal fun Project.configureForRootProject() { delete(rootProject.buildDir) } tasks.withType<Wrapper> { - gradleVersion = "6.8.1" + gradleVersion = "6.8.2" distributionType = Wrapper.DistributionType.ALL - distributionSha256Sum = "3db89524a3981819ff28c3f979236c1274a726e146ced0c8a2020417f9bc0782" + distributionSha256Sum = "1433372d903ffba27496f8d5af24265310d2da0d78bf6b4e5138831d4fe066e9" } configureBinaryCompatibilityValidator() } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index fd90863a..fd0a74c1 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -9,8 +9,8 @@ object Plugins { val androidGradlePlugin = "com.android.tools.build:gradle:4.1.1" val binaryCompatibilityValidator = "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4" val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1" - val jsemver = "com.github.zafarkhaja:java-semver:0.9.0" val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" + val semver4j = "com.vdurmont:semver4j:3.1.0" } object Dependencies { @@ -39,7 +39,7 @@ object Dependencies { const val lifecycle_common = "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" const val lifecycle_livedata_ktx = "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" const val lifecycle_viewmodel_ktx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" - const val material = "com.google.android.material:material:1.3.0-rc01" + const val material = "com.google.android.material:material:1.3.0" const val preference = "androidx.preference:preference:1.1.1" const val recycler_view = "androidx.recyclerview:recyclerview:1.2.0-beta01" const val recycler_view_selection = "androidx.recyclerview:recyclerview-selection:1.1.0" diff --git a/buildSrc/src/main/java/VersioningPlugin.kt b/buildSrc/src/main/java/VersioningPlugin.kt index 7ff9709f..a2c9ff81 100644 --- a/buildSrc/src/main/java/VersioningPlugin.kt +++ b/buildSrc/src/main/java/VersioningPlugin.kt @@ -5,7 +5,7 @@ import com.android.build.gradle.internal.plugins.AppPlugin -import com.github.zafarkhaja.semver.Version +import com.vdurmont.semver4j.Semver import java.io.OutputStream import java.util.Properties import org.gradle.api.Plugin @@ -33,16 +33,16 @@ class VersioningPlugin : Plugin<Project> { /** * Generate the Android 'versionCode' property */ - private fun Version.androidCode(): Int { - return majorVersion * 1_00_00 + - minorVersion * 1_00 + - patchVersion + private fun Semver.androidCode(): Int { + return major * 1_00_00 + + minor * 1_00 + + patch } /** * Write an Android-specific variant of [this] to [stream] */ - private fun Version.writeForAndroid(stream: OutputStream) { + private fun Semver.writeForAndroid(stream: OutputStream) { val newVersionCode = androidCode() val props = Properties() props.setProperty(VERSIONING_PROP_VERSION_CODE, "$newVersionCode") @@ -50,13 +50,6 @@ class VersioningPlugin : Plugin<Project> { props.store(stream, VERSIONING_PROP_COMMENT) } - /** - * Returns the same [Version], but with build metadata stripped. - */ - private fun Version.clearPreRelease(): Version { - return Version.forIntegers(majorVersion, minorVersion, patchVersion) - } - override fun apply(project: Project) { with(project) { val appPlugin = requireNotNull(plugins.findPlugin(AppPlugin::class.java)) { @@ -77,35 +70,38 @@ class VersioningPlugin : Plugin<Project> { appPlugin.extension.defaultConfig.versionName = versionName appPlugin.extension.defaultConfig.versionCode = versionCode afterEvaluate { - val version = Version.valueOf(versionName) + val version = Semver(versionName) tasks.register("clearPreRelease") { doLast { - version.clearPreRelease() + version.withClearedSuffix() .writeForAndroid(propFile.asFile.outputStream()) } } tasks.register("bumpMajor") { doLast { - version.incrementMajorVersion() + version.withIncMajor() + .withClearedSuffix() .writeForAndroid(propFile.asFile.outputStream()) } } tasks.register("bumpMinor") { doLast { - version.incrementMinorVersion() + version.withIncMinor() + .withClearedSuffix() .writeForAndroid(propFile.asFile.outputStream()) } } tasks.register("bumpPatch") { doLast { - version.incrementPatchVersion() + version.withIncPatch() + .withClearedSuffix() .writeForAndroid(propFile.asFile.outputStream()) } } tasks.register("bumpSnapshot") { doLast { - version.incrementMinorVersion() - .setPreReleaseVersion("SNAPSHOT") + version.withIncMinor() + .withSuffix("SNAPSHOT") .writeForAndroid(propFile.asFile.outputStream()) } } |