Skip to content

Commit 4433d41

Browse files
iBotPeachesCopilotCopilotIgorEisberg
authored
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 <175728472+Copilot@users.noreply.github.com> * 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 <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: IgorEisberg <igoreisberg@gmail.com>
1 parent 8261a52 commit 4433d41

7 files changed

Lines changed: 70 additions & 24 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,30 @@ jobs:
6464
- analyze-mac-aapt
6565
- analyze-linux-aapt
6666
- analyze-windows-aapt
67-
name: Build/Test (JDK ${{ matrix.java }}, ${{ matrix.os }})
67+
name: Build (JDK 17) / Test (JDK ${{ matrix.test-java }}, ${{ matrix.os }})
6868
strategy:
6969
fail-fast: true
7070
matrix:
7171
os: [ ubuntu-latest, macOS-latest, windows-latest ]
72-
java: [ 8, 11, 17, 21 ]
72+
test-java: [ 8, 11, 17, 21, 25 ]
7373
steps:
7474
- uses: actions/checkout@v7
7575
- uses: actions/setup-java@v5
7676
with:
7777
distribution: 'zulu'
78-
java-version: ${{ matrix.java }}
78+
java-version: 17
7979

8080
- uses: gradle/actions/setup-gradle@v6.2.0
8181
with:
8282
cache-provider: basic
8383

8484
- name: Build (Linux/Mac)
8585
if: runner.os != 'Windows'
86-
run: ./gradlew build shadowJar proguard
86+
run: ./gradlew build shadowJar proguard -PtestJdkVersion=${{ matrix.test-java }}
8787

8888
- name: Build (Windows)
8989
if: runner.os == 'Windows'
90-
run: ./gradlew.bat build shadowJar proguard
90+
run: ./gradlew.bat build shadowJar proguard -PtestJdkVersion=${{ matrix.test-java }}
9191

9292
upload-artifact:
9393
runs-on: ubuntu-latest

INTERNAL.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,21 @@ need a `gradle.properties` file in root with the structure:
4040
```
4141
signing.keyId={gpgKeyId}
4242
signing.password={gpgPassphrase}
43-
signing.secretKeyRingFile={gpgSecretKingRingLocation}
43+
signing.secretKeyRingFile={gpgSecretKeyRingLocation}
4444
45-
ossrhUsername={sonatypeUsername}
46-
ossrhPassword={sonatypePassword}
45+
mavenCentralUsername={sonatypeUsername}
46+
mavenCentralPassword={sonatypePassword}
4747
```
4848

49-
Release with maven with `./gradlew build shadowJar release publish`.
49+
Release to Maven with `./gradlew build shadowJar release publish`.
50+
51+
* Generate secret key ring - `gpg --export-secret-keys -o ~/.gnupg/secring.gpg`
52+
* Generate Maven password - `https://central.sonatype.com/usertoken`
5053

5154
### Building the binary.
5255

5356
> [!IMPORTANT]
54-
> In order to publish Maven artifacts you need JDK 11+.
57+
> Building Apktool (and publishing Maven artifacts) requires JDK 17+.
5558
5659
In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build
5760
the new binary version. We should not have any new commits since the tagged commit.

brut.apktool/apktool-cli/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ val shadowJar = tasks.register("shadowJar", Jar::class) {
6363
tasks.register<JavaExec>("proguard") {
6464
dependsOn("shadowJar")
6565

66-
onlyIf {
67-
JavaVersion.current().isJava11Compatible
68-
}
69-
7066
val proguardRules = file("proguard-rules.pro")
7167
val originalJar = shadowJar.map { it.outputs.files.singleFile }
7268

build.gradle.kts

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ var apktoolVersion by extra("")
99

1010
defaultTasks("build", "shadowJar", "proguard")
1111

12+
require(JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
13+
"Building Apktool requires JDK 17 or newer, but Gradle is running on JDK ${JavaVersion.current()}."
14+
}
15+
1216
// Functions
1317
val gitDescribe: String? by lazy {
1418
try {
@@ -52,9 +56,7 @@ if ("release" !in gradle.startParameter.taskNames) {
5256

5357
plugins {
5458
`java-library`
55-
if (JavaVersion.current().isJava11Compatible) {
56-
alias(libs.plugins.vanniktech.maven.publish) apply false
57-
}
59+
alias(libs.plugins.vanniktech.maven.publish) apply false
5860
}
5961

6062
allprojects {
@@ -77,15 +79,55 @@ subprojects {
7779
apply(plugin = "java-library")
7880

7981
java {
80-
sourceCompatibility = JavaVersion.VERSION_1_8
81-
targetCompatibility = JavaVersion.VERSION_1_8
82+
toolchain {
83+
languageVersion = JavaLanguageVersion.of(17)
84+
}
8285
}
8386

8487
tasks.withType<JavaCompile>().configureEach {
8588
options.encoding = "UTF-8"
89+
// Build with JDK 17, but emit Java 8 compatible bytecode against the Java 8 API.
90+
options.release.set(8)
91+
}
8692

87-
if (JavaVersion.current().isJava9Compatible) {
88-
options.release.set(8)
93+
tasks.withType<Test>().configureEach {
94+
testLogging {
95+
events("failed", "skipped")
96+
}
97+
afterSuite(KotlinClosure2<TestDescriptor, TestResult, Unit>({ descriptor, result ->
98+
// Only print the summary for the top-level suite (the task itself, not individual classes).
99+
if (descriptor.parent == null) {
100+
logger.lifecycle(
101+
"[{}] Tests: {} passed, {} failed, {} skipped (total: {})",
102+
project.name,
103+
result.successfulTestCount,
104+
result.failedTestCount,
105+
result.skippedTestCount,
106+
result.testCount
107+
)
108+
}
109+
}))
110+
}
111+
112+
// CI passes -PtestJdkVersion to run the test suite on an older JVM (8/11)
113+
// while the build itself stays on JDK 17.
114+
providers.gradleProperty("testJdkVersion").orNull?.toIntOrNull()?.let { testJdkVersion ->
115+
val toolchains = extensions.getByType<JavaToolchainService>()
116+
tasks.withType<Test>().configureEach {
117+
javaLauncher = toolchains.launcherFor {
118+
languageVersion = JavaLanguageVersion.of(testJdkVersion)
119+
// Zulu ships JDK 8 builds for every OS/arch we test on, including mac arm64.
120+
vendor = JvmVendorSpec.AZUL
121+
}
122+
doFirst {
123+
val launcher = javaLauncher.get()
124+
logger.lifecycle(
125+
"[{}] Test JVM: {} (runtime: {})",
126+
project.name,
127+
launcher.executablePath,
128+
launcher.metadata.javaRuntimeVersion
129+
)
130+
}
89131
}
90132
}
91133

@@ -94,7 +136,7 @@ subprojects {
94136
"apktool-lib", "apktool-cli"
95137
)
96138

97-
if (project.name in mavenProjects && JavaVersion.current().isJava11Compatible) {
139+
if (project.name in mavenProjects) {
98140
apply(from = "${rootProject.projectDir}/gradle/scripts/publishing.gradle")
99141
}
100142
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ r8 = "9.1.31"
99
smali = "b6365a84f4" # https://github.com/google/smali/issues/100
1010
xmlpull = "1.1.3.1"
1111
xmlunit = "2.12.0"
12-
maven-publish = "0.33.0"
12+
maven-publish = "0.37.0"
1313

1414
[libraries]
1515
baksmali = { module = "com.github.iBotPeaches.smali:smali-baksmali", version.ref = "baksmali" }

gradlew.bat

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
plugins {
2+
// Allows Gradle to auto-download the JDK requested via -PtestJdkVersion.
3+
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
4+
}
5+
16
rootProject.name = "apktool-cli"
27
include(
38
"brut.j.common", "brut.j.util", "brut.j.dir", "brut.j.xml", "brut.j.yaml",

0 commit comments

Comments
 (0)