From c85a31f885b75cf4d0a14f8a0f5ce572d8e52239 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 20 Mar 2021 13:09:52 +0530 Subject: buildSrc: properly apply ktfmt plugin and reformat Signed-off-by: Harsh Shandilya --- buildSrc/src/main/java/VersioningPlugin.kt | 48 +++++++++--------------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'buildSrc/src/main/java/VersioningPlugin.kt') 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 { 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 { 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 { 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()) } } } } -- cgit v1.2.3