Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,30 @@ 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/setup-gradle@v6.2.0
with:
cache-provider: basic

- 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
Expand Down
13 changes: 8 additions & 5 deletions INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions brut.apktool/apktool-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
58 changes: 50 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
)
}
}
}

Expand All @@ -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")
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading