Skip to content

Commit

Permalink
add Manifest injection
Browse files Browse the repository at this point in the history
  • Loading branch information
benz-ubique committed Sep 6, 2024
1 parent dc2e27f commit 324348e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
24 changes: 24 additions & 0 deletions plugin-build/plugin/src/main/java/ch/ubique/linth/LinthPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ abstract class LinthPlugin : Plugin<Project> {

val androidExtension = getAndroidExtension(project)

//hook manifestTask into android build process
val manifestTask = project.tasks.register("injectMetaDataIntoManifest", ManifestTask::class.java) { manifestTask ->

val flavorAndBuildType = mutableSetOf<Pair<String, String>>()

androidExtension.applicationVariants.forEach { variant ->
val flavor = variant.flavorName.capitalize()
val buildType = variant.buildType.name.capitalize()
flavorAndBuildType.add(flavor to buildType)
}
manifestTask.flavorAndBuildType = flavorAndBuildType
}

//hook Manifest into android build process
project.afterEvaluate {
androidExtension.applicationVariants.forEach { variant ->
variant.outputs.forEach { output ->
output.processManifestProvider.get().finalizedBy(manifestTask)
}
}
}

val iconTask = project.tasks.register("generateAppIcon", IconTask::class.java) { iconTask ->

val flavors = mutableSetOf<String>()
Expand All @@ -39,6 +61,8 @@ abstract class LinthPlugin : Plugin<Project> {
}
}



project.tasks.register("uploadToUbDiag", UploadToUbDiagTask::class.java) { uploadTask ->

uploadTask.uploadKey = extension.uploadKey.get()
Expand Down
25 changes: 25 additions & 0 deletions plugin-build/plugin/src/main/java/ch/ubique/linth/ManifestTask.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ch.ubique.linth

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

abstract class ManifestTask : DefaultTask() {

init {
description = "Inject Metadata into Manifest"
group = "linth"
}

@get:Input
abstract var flavorAndBuildType: Set<Pair<String, String>>


@TaskAction
fun injectMetadataIntoManifest() {
flavorAndBuildType.forEach { (flavor, buildType) ->
println("Injecting metadata into manifest for flavor: $flavor and buildType: $buildType")
}
}

}

0 comments on commit 324348e

Please sign in to comment.