Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.gradle.kts: Ensure custom tasks rebuild when input variables change #17

Merged
merged 1 commit into from
May 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ android.applicationVariants.all {
val variantDir = File(extraDir, variant.name)

val moduleProp = tasks.register("moduleProp${capitalized}") {
inputs.property("projectUrl", projectUrl)
inputs.property("releaseMetadataBranch", releaseMetadataBranch)
inputs.property("variant.applicationId", variant.applicationId)
inputs.property("variant.name", variant.name)
inputs.property("variant.versionCode", variant.versionCode)
inputs.property("variant.versionName", variant.versionName)

val outputFile = File(variantDir, "module.prop")
outputs.file(outputFile)

Expand All @@ -177,6 +184,8 @@ android.applicationVariants.all {
}

val permissionsXml = tasks.register("permissionsXml${capitalized}") {
inputs.property("variant.applicationId", variant.applicationId)

val outputFile = File(variantDir, "privapp-permissions-${variant.applicationId}.xml")
outputs.file(outputFile)

Expand All @@ -194,6 +203,10 @@ android.applicationVariants.all {
}

tasks.register<Zip>("zip${capitalized}") {
inputs.property("variant.applicationId", variant.applicationId)
inputs.property("variant.name", variant.name)
inputs.property("variant.versionName", variant.versionName)

archiveFileName.set("BCR-${variant.versionName}-${variant.name}.zip")
destinationDirectory.set(File(destinationDirectory.asFile.get(), variant.name))

Expand Down Expand Up @@ -221,6 +234,13 @@ android.applicationVariants.all {
}

tasks.register("updateJson${capitalized}") {
inputs.property("gitVersionTriple", gitVersionTriple)
inputs.property("projectUrl", projectUrl)
inputs.property("releaseMetadataBranch", releaseMetadataBranch)
inputs.property("variant.name", variant.name)
inputs.property("variant.versionCode", variant.versionCode)
inputs.property("variant.versionName", variant.versionName)

val magiskDir = File(projectDir, "magisk")
val updatesDir = File(magiskDir, "updates")
val variantUpdateDir = File(updatesDir, variant.name)
Expand All @@ -231,6 +251,10 @@ android.applicationVariants.all {
outputs.file(changelogFile)

doLast {
if (gitVersionTriple.second != 0) {
throw IllegalStateException("The release tag must be checked out")
}

val root = JSONObject()
root.put("version", variant.versionName)
root.put("versionCode", variant.versionCode)
Expand Down