From 11d6fc059e232754cd991d334febbbd03f15ddf5 Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Fri, 10 Jul 2020 10:32:29 +0200 Subject: [PATCH] Add separate option for keeping mapping and bundle files * bump version to 2.4.0 --- README.md | 14 ++++++++------ build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../de/nanogiants/gradle/VersioningPlugin.kt | 8 ++++---- .../nanogiants/gradle/VersioningPluginExtension.kt | 3 ++- .../kotlin/de/nanogiants/gradle/ext/TaskExt.kt | 6 +++--- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5bef110..c72329e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The plugin is available from the GradlePluginPortal (preferred) and jcenter. ```kotlin // app build.gradle.kts plugins { - id("de.nanogiants.android-versioning") version "2.3.1" + id("de.nanogiants.android-versioning") version "2.4.0" } ``` @@ -22,7 +22,7 @@ plugins { ```groovy // app build.gradle plugins { - id 'de.nanogiants.android-versioning' version '2.3.1' + id 'de.nanogiants.android-versioning' version '2.4.0' } ``` @@ -37,7 +37,7 @@ or via the // top-level build.gradle.kts buildscript { dependencies { - classpath("de.nanogiants:android-versioning:2.3.1") + classpath("de.nanogiants:android-versioning:2.4.0") } } ``` @@ -54,7 +54,7 @@ apply(plugin = "de.nanogiants.android-versioning") // top-level build.gradle buildscript { dependencies { - classpath 'de.nanogiants:android-versioning:2.3.1' + classpath 'de.nanogiants:android-versioning:2.4.0' } } ``` @@ -103,12 +103,14 @@ Because Android Studio does not know about the AAB renaming, the `locate` or `an #### Customization: * `excludeBuildTypes`: comma separated list of buildTypes (e.g. debug) to be excluded from the artifact naming -* `keepOriginalArtifacts`: copy artifact files instead of renaming them +* `keepOriginalBundleFile`: copy ABB files instead of renaming them (default *false*) +* `keepOriginalMappingFile`: copy mapping files instead of renaming them (default *true* to avoid caching issues) ```groovy // app build.gradle versioning { excludeBuildTypes = "debug" // default: null - keepOriginalArtifacts = true // default: false + keepOriginalBundleFile = true // default: false + keepOriginalMappingFile = false // default: true } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 8415cc5..2dc1c5c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "de.nanogiants" -version = "2.3.1" +version = "2.4.0" repositories { google() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 186b715..ac33e99 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/de/nanogiants/gradle/VersioningPlugin.kt b/src/main/kotlin/de/nanogiants/gradle/VersioningPlugin.kt index 0c281ac..35a055e 100644 --- a/src/main/kotlin/de/nanogiants/gradle/VersioningPlugin.kt +++ b/src/main/kotlin/de/nanogiants/gradle/VersioningPlugin.kt @@ -8,7 +8,7 @@ package de.nanogiants.gradle import com.android.build.gradle.AppExtension import com.android.build.gradle.internal.api.BaseVariantOutputImpl import de.nanogiants.gradle.ext.addPrintOutputAction -import de.nanogiants.gradle.ext.addRenameArtifactAction +import de.nanogiants.gradle.ext.addRenameBundleAction import de.nanogiants.gradle.ext.addRenameMappingAction import de.nanogiants.gradle.ext.generateOutputName import de.nanogiants.gradle.ext.getAPKPath @@ -63,12 +63,12 @@ class VersioningPlugin : Plugin { val newBundleName = variant.generateOutputName(baseName, "aab") val bundleOutputPath = variant.getBundlePath(buildDir) - task.addRenameArtifactAction(bundleName, newBundleName, bundleOutputPath, ext.keepOriginalArtifacts) + task.addRenameBundleAction(bundleName, newBundleName, bundleOutputPath, ext.keepOriginalBundleFile) if (variant.buildType.isMinifyEnabled) { variant.mappingFileProvider.orNull?.firstOrNull()?.let { val newMappingName = variant.generateOutputName(baseName, "txt") - task.addRenameMappingAction(it, newMappingName, ext.keepOriginalArtifacts) + task.addRenameMappingAction(it, newMappingName, ext.keepOriginalMappingFile) } } } @@ -87,7 +87,7 @@ class VersioningPlugin : Plugin { if (variant.buildType.isMinifyEnabled) { variant.mappingFileProvider.orNull?.firstOrNull()?.let { val newMappingName = variant.generateOutputName(baseName, "txt") - task.addRenameMappingAction(it, newMappingName, ext.keepOriginalArtifacts) + task.addRenameMappingAction(it, newMappingName, ext.keepOriginalMappingFile) } } } diff --git a/src/main/kotlin/de/nanogiants/gradle/VersioningPluginExtension.kt b/src/main/kotlin/de/nanogiants/gradle/VersioningPluginExtension.kt index 0d67061..900ef61 100644 --- a/src/main/kotlin/de/nanogiants/gradle/VersioningPluginExtension.kt +++ b/src/main/kotlin/de/nanogiants/gradle/VersioningPluginExtension.kt @@ -17,5 +17,6 @@ open class VersioningPluginExtension { fun getVersionName(checkBranch: Boolean = false) = if (checkBranch) lazyVersionNameCheckBranch else lazyVersionName var excludeBuildTypes: String? = null - var keepOriginalArtifacts: Boolean = false + var keepOriginalBundleFile: Boolean = false + var keepOriginalMappingFile: Boolean = true } \ No newline at end of file diff --git a/src/main/kotlin/de/nanogiants/gradle/ext/TaskExt.kt b/src/main/kotlin/de/nanogiants/gradle/ext/TaskExt.kt index 9b3d343..258d1f6 100644 --- a/src/main/kotlin/de/nanogiants/gradle/ext/TaskExt.kt +++ b/src/main/kotlin/de/nanogiants/gradle/ext/TaskExt.kt @@ -8,7 +8,7 @@ package de.nanogiants.gradle.ext import org.gradle.api.Task import java.io.File -internal fun Task.addRenameArtifactAction( +internal fun Task.addRenameBundleAction( oldOutput: String, newOutput: String, outputPath: String, @@ -30,7 +30,7 @@ internal fun Task.addRenameArtifactAction( } } else { if (newFile.exists()) { - println("Cached output $oldOutput was already renamed. Set 'keepOriginalArtifacts' if you like to keep those files.") + println("Cached output $oldOutput was already renamed. Set 'keepOriginalBundleFile' if you like to keep those files.") } else { logger.error("$oldOutput and $newOutput not found. Try a clean build.") } @@ -54,7 +54,7 @@ internal fun Task.addRenameMappingAction(oldOutput: File, newOutput: String, kee } } else { if (newFile.exists()) { - println("Cached output mapping.txt was already renamed. Set 'keepOriginalArtifacts' if you like to keep those files.") + println("Cached output mapping.txt was already renamed. Set 'keepOriginalMappingFile' if you like to keep those files.") } else { logger.error("mapping.txt and $newOutput not found. Try a clean build.") }