build: move required build to JDK 17, support Java 8. (#4175)

* feat: move to v0.37.0

* chore: maven publish is jdk 17+

* wip

* build: test on Java 25 as well

* chore: fix feedback from Copilot

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* build: log test JVM path and version in doFirst to confirm toolchain selection

* build: add test summary and failed/skipped event logging to all Test tasks

* Some cleanup

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: IgorEisberg <[email protected]>
This commit is contained in:
Connor Tumbleson
2026-07-24 06:22:19 -04:00
committed by GitHub
co-authored by Copilot Autofix powered by AI copilot-swe-agent[bot] IgorEisberg
parent 8261a526e0
commit 4433d41587
7 changed files with 70 additions and 24 deletions
+5 -5
View File
@@ -64,18 +64,18 @@ jobs:
- analyze-mac-aapt
- analyze-linux-aapt
- analyze-windows-aapt
name: Build/Test (JDK ${{ matrix.java }}, ${{ matrix.os }})
name: Build (JDK 17) / Test (JDK ${{ matrix.test-java }}, ${{ matrix.os }})
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
java: [ 8, 11, 17, 21 ]
test-java: [ 8, 11, 17, 21, 25 ]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
java-version: 17
- uses: gradle/actions/[email protected]
with:
@@ -83,11 +83,11 @@ jobs:
- name: Build (Linux/Mac)
if: runner.os != 'Windows'
run: ./gradlew build shadowJar proguard
run: ./gradlew build shadowJar proguard -PtestJdkVersion=${{ matrix.test-java }}
- name: Build (Windows)
if: runner.os == 'Windows'
run: ./gradlew.bat build shadowJar proguard
run: ./gradlew.bat build shadowJar proguard -PtestJdkVersion=${{ matrix.test-java }}
upload-artifact:
runs-on: ubuntu-latest
+8 -5
View File
@@ -40,18 +40,21 @@ need a `gradle.properties` file in root with the structure:
```
signing.keyId={gpgKeyId}
signing.password={gpgPassphrase}
signing.secretKeyRingFile={gpgSecretKingRingLocation}
signing.secretKeyRingFile={gpgSecretKeyRingLocation}
ossrhUsername={sonatypeUsername}
ossrhPassword={sonatypePassword}
mavenCentralUsername={sonatypeUsername}
mavenCentralPassword={sonatypePassword}
```
Release with maven with `./gradlew build shadowJar release publish`.
Release to Maven with `./gradlew build shadowJar release publish`.
* Generate secret key ring - `gpg --export-secret-keys -o ~/.gnupg/secring.gpg`
* Generate Maven password - `https://central.sonatype.com/usertoken`
### Building the binary.
> [!IMPORTANT]
> In order to publish Maven artifacts you need JDK 11+.
> Building Apktool (and publishing Maven artifacts) requires JDK 17+.
In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build
the new binary version. We should not have any new commits since the tagged commit.
@@ -63,10 +63,6 @@ val shadowJar = tasks.register("shadowJar", Jar::class) {
tasks.register<JavaExec>("proguard") {
dependsOn("shadowJar")
onlyIf {
JavaVersion.current().isJava11Compatible
}
val proguardRules = file("proguard-rules.pro")
val originalJar = shadowJar.map { it.outputs.files.singleFile }
+50 -8
View File
@@ -9,6 +9,10 @@ var apktoolVersion by extra("")
defaultTasks("build", "shadowJar", "proguard")
require(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
"Building Apktool requires JDK 17 or newer, but Gradle is running on JDK ${JavaVersion.current()}."
}
// Functions
val gitDescribe: String? by lazy {
try {
@@ -52,9 +56,7 @@ if ("release" !in gradle.startParameter.taskNames) {
plugins {
`java-library`
if (JavaVersion.current().isJava11Compatible) {
alias(libs.plugins.vanniktech.maven.publish) apply false
}
alias(libs.plugins.vanniktech.maven.publish) apply false
}
allprojects {
@@ -77,15 +79,55 @@ subprojects {
apply(plugin = "java-library")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
// Build with JDK 17, but emit Java 8 compatible bytecode against the Java 8 API.
options.release.set(8)
}
if (JavaVersion.current().isJava9Compatible) {
options.release.set(8)
tasks.withType<Test>().configureEach {
testLogging {
events("failed", "skipped")
}
afterSuite(KotlinClosure2<TestDescriptor, TestResult, Unit>({ descriptor, result ->
// Only print the summary for the top-level suite (the task itself, not individual classes).
if (descriptor.parent == null) {
logger.lifecycle(
"[{}] Tests: {} passed, {} failed, {} skipped (total: {})",
project.name,
result.successfulTestCount,
result.failedTestCount,
result.skippedTestCount,
result.testCount
)
}
}))
}
// CI passes -PtestJdkVersion to run the test suite on an older JVM (8/11)
// while the build itself stays on JDK 17.
providers.gradleProperty("testJdkVersion").orNull?.toIntOrNull()?.let { testJdkVersion ->
val toolchains = extensions.getByType<JavaToolchainService>()
tasks.withType<Test>().configureEach {
javaLauncher = toolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(testJdkVersion)
// Zulu ships JDK 8 builds for every OS/arch we test on, including mac arm64.
vendor = JvmVendorSpec.AZUL
}
doFirst {
val launcher = javaLauncher.get()
logger.lifecycle(
"[{}] Test JVM: {} (runtime: {})",
project.name,
launcher.executablePath,
launcher.metadata.javaRuntimeVersion
)
}
}
}
@@ -94,7 +136,7 @@ subprojects {
"apktool-lib", "apktool-cli"
)
if (project.name in mavenProjects && JavaVersion.current().isJava11Compatible) {
if (project.name in mavenProjects) {
apply(from = "${rootProject.projectDir}/gradle/scripts/publishing.gradle")
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ r8 = "9.1.31"
smali = "b6365a84f4" # https://github.com/google/smali/issues/100
xmlpull = "1.1.3.1"
xmlunit = "2.12.0"
maven-publish = "0.33.0"
maven-publish = "0.37.0"
[libraries]
baksmali = { module = "com.github.iBotPeaches.smali:smali-baksmali", version.ref = "baksmali" }
Vendored
+1 -1
View File
@@ -53,7 +53,7 @@ goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
set JAVA_EXE=%JAVA_HOME%\bin\java.exe
if exist "%JAVA_EXE%" goto execute
+5
View File
@@ -1,3 +1,8 @@
plugins {
// Allows Gradle to auto-download the JDK requested via -PtestJdkVersion.
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
rootProject.name = "apktool-cli"
include(
"brut.j.common", "brut.j.util", "brut.j.dir", "brut.j.xml", "brut.j.yaml",