aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/java/VersioningPlugin.kt
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/java/VersioningPlugin.kt')
-rw-r--r--buildSrc/src/main/java/VersioningPlugin.kt48
1 files changed, 14 insertions, 34 deletions
diff --git a/buildSrc/src/main/java/VersioningPlugin.kt b/buildSrc/src/main/java/VersioningPlugin.kt
index f05aa34e..30ca5895 100644
--- a/buildSrc/src/main/java/VersioningPlugin.kt
+++ b/buildSrc/src/main/java/VersioningPlugin.kt
@@ -14,7 +14,7 @@ private const val VERSIONING_PROP_FILE = "version.properties"
private const val VERSIONING_PROP_VERSION_NAME = "versioning-plugin.versionName"
private const val VERSIONING_PROP_VERSION_CODE = "versioning-plugin.versionCode"
private const val VERSIONING_PROP_COMMENT =
- """
+ """
This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
"""
@@ -44,9 +44,9 @@ class VersioningPlugin : Plugin<Project> {
override fun apply(project: Project) {
with(project) {
val appPlugin =
- requireNotNull(plugins.findPlugin(AppPlugin::class.java)) {
- "Plugin 'com.android.application' must be applied to use this plugin"
- }
+ requireNotNull(plugins.findPlugin(AppPlugin::class.java)) {
+ "Plugin 'com.android.application' must be applied to use this plugin"
+ }
val propFile = layout.projectDirectory.file(VERSIONING_PROP_FILE)
require(propFile.asFile.exists()) {
"A 'version.properties' file must exist in the project subdirectory to use this plugin"
@@ -54,13 +54,13 @@ class VersioningPlugin : Plugin<Project> {
val contents = providers.fileContents(propFile).asText.forUseAtConfigurationTime()
val versionProps = Properties().also { it.load(contents.get().byteInputStream()) }
val versionName =
- requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_NAME)) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_NAME' property"
- }
+ requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_NAME)) {
+ "version.properties must contain a '$VERSIONING_PROP_VERSION_NAME' property"
+ }
val versionCode =
- requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_CODE).toInt()) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_CODE' property"
- }
+ requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_CODE).toInt()) {
+ "version.properties must contain a '$VERSIONING_PROP_VERSION_CODE' property"
+ }
appPlugin.extension.defaultConfig.versionName = versionName
appPlugin.extension.defaultConfig.versionCode = versionCode
afterEvaluate {
@@ -69,36 +69,16 @@ class VersioningPlugin : Plugin<Project> {
doLast { version.withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
}
tasks.register("bumpMajor") {
- doLast {
- version
- .withIncMajor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ doLast { version.withIncMajor().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
}
tasks.register("bumpMinor") {
- doLast {
- version
- .withIncMinor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ doLast { version.withIncMinor().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
}
tasks.register("bumpPatch") {
- doLast {
- version
- .withIncPatch()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ doLast { version.withIncPatch().withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
}
tasks.register("bumpSnapshot") {
- doLast {
- version
- .withIncMinor()
- .withSuffix("SNAPSHOT")
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ doLast { version.withIncMinor().withSuffix("SNAPSHOT").writeForAndroid(propFile.asFile.outputStream()) }
}
}
}