diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-03-20 13:09:52 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-03-20 14:58:17 +0530 |
commit | c85a31f885b75cf4d0a14f8a0f5ce572d8e52239 (patch) | |
tree | aa047f7b51a41af1f58a0d69de40a38418f27a39 /buildSrc/src/main/java/VersioningPlugin.kt | |
parent | fbfe7dcb1e66c6240f8c8e90a85113102a175693 (diff) |
buildSrc: properly apply ktfmt plugin and reformat
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'buildSrc/src/main/java/VersioningPlugin.kt')
-rw-r--r-- | buildSrc/src/main/java/VersioningPlugin.kt | 48 |
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()) } } } } |