From 955fe8dd4abf8e4771cc7aa8933efd4a157ea86d Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Thu, 11 Jun 2020 02:31:16 +0200 Subject: [PATCH 1/3] Fix apk output path generation --- .../eu/nanogiants/gradle/VersioningPlugin.kt | 3 ++- .../nanogiants/gradle/ext/ApplicationVariantExt.kt | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt b/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt index 535094e..cd5175c 100644 --- a/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt +++ b/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt @@ -10,6 +10,7 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl import eu.nanogiants.gradle.ext.addPrintOutputAction import eu.nanogiants.gradle.ext.addRenameArtifactAction import eu.nanogiants.gradle.ext.addRenameMappingAction +import eu.nanogiants.gradle.ext.generateAPKPath import eu.nanogiants.gradle.ext.generateOutputName import eu.nanogiants.gradle.ext.listContains import org.gradle.api.Plugin @@ -78,7 +79,7 @@ class VersioningPlugin : Plugin { if (variant.name == variantName && !ext.excludeBuildTypes.listContains(variant.buildType.name)) { variant.outputs.configureEach { val apkName = (it as BaseVariantOutputImpl).outputFileName - val apkOutputPath = "${buildDir.absolutePath}/outputs/apk/$variantName/" + val apkOutputPath = variant.generateAPKPath(buildDir) task.addPrintOutputAction(apkOutputPath, apkName) } diff --git a/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt b/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt index 94eedfd..cd12f05 100644 --- a/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt +++ b/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt @@ -6,6 +6,7 @@ package eu.nanogiants.gradle.ext import com.android.build.gradle.api.ApplicationVariant +import java.io.File internal fun ApplicationVariant.generateOutputName(baseName: String, extension: String): String { return StringBuilder().apply { @@ -28,4 +29,17 @@ internal fun ApplicationVariant.generateOutputName(baseName: String, extension: append(".") append(extension) }.toString() +} + +internal fun ApplicationVariant.generateAPKPath(buildDir: File): String { + return StringBuilder().apply { + append(buildDir.absolutePath) + append("/outputs/apk/") + if (flavorName.isNotEmpty()) { + append(flavorName) + append("/") + } + append(buildType.name) + append("/") + }.toString() } \ No newline at end of file From 0925b8fc780ee6cfcd89ee79ed810f1df3bf0dad Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Thu, 11 Jun 2020 09:30:58 +0200 Subject: [PATCH 2/3] Refactor apk and bundle path generation --- .../kotlin/eu/nanogiants/gradle/VersioningPlugin.kt | 7 ++++--- .../eu/nanogiants/gradle/ext/ApplicationVariantExt.kt | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt b/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt index cd5175c..c6239b1 100644 --- a/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt +++ b/src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt @@ -10,8 +10,9 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl import eu.nanogiants.gradle.ext.addPrintOutputAction import eu.nanogiants.gradle.ext.addRenameArtifactAction import eu.nanogiants.gradle.ext.addRenameMappingAction -import eu.nanogiants.gradle.ext.generateAPKPath import eu.nanogiants.gradle.ext.generateOutputName +import eu.nanogiants.gradle.ext.getAPKPath +import eu.nanogiants.gradle.ext.getBundlePath import eu.nanogiants.gradle.ext.listContains import org.gradle.api.Plugin import org.gradle.api.Project @@ -60,7 +61,7 @@ class VersioningPlugin : Plugin { if (variant.name == variantName && !ext.excludeBuildTypes.listContains(variant.buildType.name)) { val bundleName = "$baseName-${variant.baseName}.aab" val newBundleName = variant.generateOutputName(baseName, "aab") - val bundleOutputPath = "${buildDir.absolutePath}/outputs/bundle/${variant.name}/" + val bundleOutputPath = variant.getBundlePath(buildDir) task.addRenameArtifactAction(bundleName, newBundleName, bundleOutputPath, ext.keepOriginalArtifacts) @@ -79,7 +80,7 @@ class VersioningPlugin : Plugin { if (variant.name == variantName && !ext.excludeBuildTypes.listContains(variant.buildType.name)) { variant.outputs.configureEach { val apkName = (it as BaseVariantOutputImpl).outputFileName - val apkOutputPath = variant.generateAPKPath(buildDir) + val apkOutputPath = variant.getAPKPath(buildDir) task.addPrintOutputAction(apkOutputPath, apkName) } diff --git a/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt b/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt index cd12f05..49688fb 100644 --- a/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt +++ b/src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt @@ -31,7 +31,16 @@ internal fun ApplicationVariant.generateOutputName(baseName: String, extension: }.toString() } -internal fun ApplicationVariant.generateAPKPath(buildDir: File): String { +internal fun ApplicationVariant.getBundlePath(buildDir: File): String { + return StringBuilder().apply { + append(buildDir.absolutePath) + append("/outputs/bundle/") + append(name) + append("/") + }.toString() +} + +internal fun ApplicationVariant.getAPKPath(buildDir: File): String { return StringBuilder().apply { append(buildDir.absolutePath) append("/outputs/apk/") From af187671ed793146c6b6114796dedd284432fe5f Mon Sep 17 00:00:00 2001 From: Thomas Wirth Date: Sun, 14 Jun 2020 20:20:43 +0200 Subject: [PATCH 3/3] Bump version to 2.2.1 --- README.md | 2 +- build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53509bb..18fe1c9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ buildscript { jcenter() } dependencies { - classpath 'eu.nanogiants:android-versioning:2.2.0' + classpath 'eu.nanogiants:android-versioning:2.2.1' } } ``` diff --git a/build.gradle.kts b/build.gradle.kts index ff8ff4b..fc918d2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "eu.nanogiants" -version = "2.2.0" +version = "2.2.1" repositories { google()