Skip to content

Commit

Permalink
Merge branch 'release/2.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Jun 14, 2020
2 parents e5f1ee5 + af18767 commit 1e9ae9b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'eu.nanogiants:android-versioning:2.2.0'
classpath 'eu.nanogiants:android-versioning:2.2.1'
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "eu.nanogiants"
version = "2.2.0"
version = "2.2.1"

repositories {
google()
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/eu/nanogiants/gradle/VersioningPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import eu.nanogiants.gradle.ext.addPrintOutputAction
import eu.nanogiants.gradle.ext.addRenameArtifactAction
import eu.nanogiants.gradle.ext.addRenameMappingAction
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
Expand Down Expand Up @@ -59,7 +61,7 @@ class VersioningPlugin : Plugin<Project> {
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)

Expand All @@ -78,7 +80,7 @@ class VersioningPlugin : Plugin<Project> {
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.getAPKPath(buildDir)
task.addPrintOutputAction(apkOutputPath, apkName)
}

Expand Down
23 changes: 23 additions & 0 deletions src/main/kotlin/eu/nanogiants/gradle/ext/ApplicationVariantExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,4 +29,26 @@ internal fun ApplicationVariant.generateOutputName(baseName: String, extension:
append(".")
append(extension)
}.toString()
}

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/")
if (flavorName.isNotEmpty()) {
append(flavorName)
append("/")
}
append(buildType.name)
append("/")
}.toString()
}

0 comments on commit 1e9ae9b

Please sign in to comment.