diff --git a/plugin-build/plugin/src/main/java/ch/ubique/linth/InjectMetaIntoManifestTask.kt b/plugin-build/plugin/src/main/java/ch/ubique/linth/InjectMetaIntoManifestTask.kt
index 4d0d4a4..773d730 100644
--- a/plugin-build/plugin/src/main/java/ch/ubique/linth/InjectMetaIntoManifestTask.kt
+++ b/plugin-build/plugin/src/main/java/ch/ubique/linth/InjectMetaIntoManifestTask.kt
@@ -1,10 +1,9 @@
package ch.ubique.linth
import ch.ubique.linth.common.GitUtils
-import ch.ubique.linth.common.capitalize
+import ch.ubique.linth.common.getMergedManifestFile
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import java.io.File
@@ -15,20 +14,17 @@ abstract class InjectMetaIntoManifestTask : DefaultTask() {
private val METADATA_KEY_BRANCH = "ch.ubique.linth.branch"
private val METADATA_KEY_FLAVOR = "ch.ubique.linth.flavor"
-
private var buildId: String = "0"
private var buildNumber: String = "0"
private var buildBranch: String = "master"
private var buildFlavor: String = "default"
-
init {
description = "Inject Metadata into Manifest"
group = "linth"
buildId = project.findProperty("buildid")?.toString() ?: project.findProperty("ubappid")?.toString() ?: "localbuild"
buildNumber = project.findProperty("buildnumber")?.toString() ?: "0"
buildBranch = project.findProperty("branch")?.toString() ?: GitUtils.obtainBranch()
-
}
@get:Input
@@ -37,18 +33,12 @@ abstract class InjectMetaIntoManifestTask : DefaultTask() {
@TaskAction
fun injectMetadataIntoManifest() {
flavorAndBuildType.forEach { (flavor, buildType) ->
- println("Injecting metadata into manifest for flavor: $flavor and buildType: $buildType")
- val variantName = flavor + buildType.capitalize()
- val manifestFile = File(
- project.layout.buildDirectory.asFile.get(),
- "intermediates/merged_manifests/${variantName}/process${variantName}Manifest/AndroidManifest.xml"
- )
+ val manifestFile = project.getMergedManifestFile(flavor, buildType)
if (manifestFile.exists()) {
manipulateManifestFile(manifestFile)
} else {
println("Manifest file not found for flavor: $flavor and buildType: $buildType")
}
-
}
}
@@ -82,7 +72,7 @@ abstract class InjectMetaIntoManifestTask : DefaultTask() {
private fun addMetaData(manifest: String, metaName: String, metaValue: String): String {
val xmlAppClosingTag = ""
val metaTag = ""
- return manifest.replace("${xmlAppClosingTag}", " $metaTag\n $xmlAppClosingTag")
+ return manifest.replace(xmlAppClosingTag, " $metaTag\n $xmlAppClosingTag")
}
}
\ No newline at end of file
diff --git a/plugin-build/plugin/src/main/java/ch/ubique/linth/LinthPlugin.kt b/plugin-build/plugin/src/main/java/ch/ubique/linth/LinthPlugin.kt
index 5d0c12c..133bdeb 100644
--- a/plugin-build/plugin/src/main/java/ch/ubique/linth/LinthPlugin.kt
+++ b/plugin-build/plugin/src/main/java/ch/ubique/linth/LinthPlugin.kt
@@ -27,7 +27,7 @@ abstract class LinthPlugin : Plugin {
manifestTask.flavorAndBuildType = flavorAndBuildType
}
- //hook Manifest into android build process
+ //hook injectMetaTask into android build process
project.afterEvaluate {
androidExtension.applicationVariants.forEach { variant ->
variant.outputs.forEach { output ->
diff --git a/plugin-build/plugin/src/main/java/ch/ubique/linth/common/GitUtils.kt b/plugin-build/plugin/src/main/java/ch/ubique/linth/common/GitUtils.kt
index 41627b8..fed3d7e 100644
--- a/plugin-build/plugin/src/main/java/ch/ubique/linth/common/GitUtils.kt
+++ b/plugin-build/plugin/src/main/java/ch/ubique/linth/common/GitUtils.kt
@@ -19,7 +19,6 @@ object GitUtils {
if (branchName.isEmpty()) {
branchName = "develop"
}
- println("Branch name: $branchName")
return branchName
}