Skip to content

Commit

Permalink
refactor: use native Gradle "fatJar" method
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Mar 31, 2024
1 parent 75c7053 commit 6ea3372
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions brut.apktool/apktool-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ application {
tasks.run.get().workingDir = file(System.getProperty("user.dir"))
}

tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "brut.apktool.Main"
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}

tasks.register<Delete>("cleanOutputDirectory") {
Expand All @@ -39,8 +38,23 @@ tasks.register<Delete>("cleanOutputDirectory") {
})
}

tasks.create("shadowJar", Jar::class) {
dependsOn("build")
group = "build"
description = "Creates a single executable JAR with all dependencies"
manifest.attributes["Main-Class"] = "brut.apktool.Main"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

val dependencies = configurations
.runtimeClasspath
.get()
.map(::zipTree)

from(dependencies)
with(tasks.jar.get())
}

tasks.register<ProGuardTask>("proguard") {
dependsOn("cleanOutputDirectory")
dependsOn("shadowJar")
injars(tasks.named("shadowJar").get().outputs.files)

Expand Down Expand Up @@ -70,3 +84,5 @@ tasks.register<ProGuardTask>("proguard") {
val outPath = "build/libs/apktool-$apktoolVersion.jar"
outjars(outPath)
}

tasks.getByPath(":release").dependsOn("proguard")

0 comments on commit 6ea3372

Please sign in to comment.