From 012f7665aaddaf0eea023cfb8a61e4890d60a161 Mon Sep 17 00:00:00 2001 From: Skylot Date: Thu, 15 Apr 2021 12:37:44 +0100 Subject: [PATCH] chore: update gradle to 7.0, update dependencies, fix some build warnings --- .gitlab-ci.yml | 11 ++++-- build.gradle | 45 ++++++++++++++-------- gradle/wrapper/gradle-wrapper.properties | 4 +- jadx-cli/build.gradle | 2 +- jadx-core/build.gradle | 2 +- jadx-gui/build.gradle | 15 +++++--- jadx-plugins/jadx-dex-input/build.gradle | 2 +- jadx-plugins/jadx-smali-input/build.gradle | 2 +- jadx-samples/build.gradle | 2 +- 9 files changed, 54 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f3220ab..894c8b5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,14 +11,19 @@ stages: java-8: stage: test image: openjdk:8 - script: ./gradlew clean build dist + script: ./gradlew clean build dist --warning-mode=all java-11: stage: test image: openjdk:11 - script: ./gradlew clean build dist + script: ./gradlew clean build dist --warning-mode=all + +java-15: + stage: test + image: openjdk:15 + script: ./gradlew clean build dist --warning-mode=all java-latest: stage: test image: openjdk:latest - script: java -version && ./gradlew clean build dist + script: java -version && ./gradlew clean build dist --warning-mode=all diff --git a/build.gradle b/build.gradle index 7cc6baab..56def4b5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'com.github.ben-manes.versions' version '0.38.0' - id "com.diffplug.spotless" version "5.11.0" + id "com.diffplug.spotless" version "5.12.4" } ext.jadxVersion = System.getenv('JADX_VERSION') ?: "dev" @@ -38,7 +38,7 @@ allprojects { testImplementation 'ch.qos.logback:logback-classic:1.2.3' testImplementation 'org.hamcrest:hamcrest-library:2.2' - testImplementation 'org.mockito:mockito-core:3.8.0' + testImplementation 'org.mockito:mockito-core:3.9.0' testImplementation 'org.assertj:assertj-core:3.19.0' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1' @@ -75,7 +75,12 @@ spotless { importOrderFile 'config/code-formatter/eclipse.importorder' eclipse().configFile 'config/code-formatter/eclipse.xml' - removeUnusedImports() + if (JavaVersion.current() < JavaVersion.VERSION_16) { + removeUnusedImports() + } else { + // google-format broken on java 16 (https://github.com/diffplug/spotless/issues/834) + println('Warning! Unused imports remove is disabled for Java 16') + } lineEndings(com.diffplug.spotless.LineEnding.UNIX) encoding("UTF-8") @@ -108,32 +113,42 @@ dependencyUpdates { } } -task copyArtifacts(type: Sync, dependsOn: ['jadx-cli:installDist', 'jadx-gui:installDist']) { - destinationDir file("$buildDir/jadx") - ['jadx-cli', 'jadx-gui'].each { - from tasks.getByPath(":${it}:installDist").destinationDir - } +task copyArtifacts(type: Copy) { + from tasks.getByPath(":jadx-cli:installDist") + from tasks.getByPath(":jadx-gui:installDist") + into layout.buildDirectory.dir("jadx") duplicatesStrategy = DuplicatesStrategy.EXCLUDE } -task pack(type: Zip, dependsOn: copyArtifacts) { - destinationDirectory = buildDir +task pack(type: Zip) { + from copyArtifacts archiveFileName = "jadx-${jadxVersion}.zip" - from copyArtifacts.destinationDir + destinationDirectory = layout.buildDirectory } -task copyExe(type: Copy, dependsOn: 'jadx-gui:createExe') { +task copyExe(type: Copy) { group 'jadx' description = 'Copy exe to build dir' - destinationDir buildDir - from tasks.getByPath('jadx-gui:createExe').outputs + mustRunAfter pack // not needed, but gradle throws warning because of same output dir + + from tasks.getByPath('jadx-gui:createExe') include '*.exe' + into layout.buildDirectory duplicatesStrategy = DuplicatesStrategy.EXCLUDE } -task dist(dependsOn: [pack, copyExe]) { +task dist { group 'jadx' description = 'Build jadx distribution zip' + + dependsOn(pack) + if (JavaVersion.current() < JavaVersion.VERSION_16) { + dependsOn('copyExe') + } else { + // shadow jar plugin broken on java 16 (https://github.com/johnrengelman/shadow/issues/658) + tasks.getByPath(':jadx-gui:shadowJar').enabled = false + println('Warning! Build of jadx-gui.exe disabled for Java 16') + } } task samples(dependsOn: 'jadx-samples:samples') { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 87e87435..d6aa5ac2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=e2774e6fb77c43657decde25542dea710aafd78c4022d19b196e7e78d79d8c6c -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionSha256Sum=eb8b89184261025b0430f5b2233701ff1377f96da1ef5e278af6ae8bac5cc305 +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jadx-cli/build.gradle b/jadx-cli/build.gradle index 4b2e4030..6c65aa89 100644 --- a/jadx-cli/build.gradle +++ b/jadx-cli/build.gradle @@ -15,7 +15,7 @@ dependencies { application { applicationName = 'jadx' - mainClassName = 'jadx.cli.JadxCLI' + mainClass.set('jadx.cli.JadxCLI') applicationDefaultJvmArgs = ['-Xms128M', '-Xmx4g', '-XX:+UseG1GC'] } diff --git a/jadx-core/build.gradle b/jadx-core/build.gradle index c5db6794..2be78f25 100644 --- a/jadx-core/build.gradle +++ b/jadx-core/build.gradle @@ -6,7 +6,7 @@ dependencies { api(project(':jadx-plugins:jadx-plugins-api')) implementation 'com.google.code.gson:gson:2.8.6' - implementation 'com.android.tools.build:aapt2-proto:4.1.2-6503028' + implementation 'com.android.tools.build:aapt2-proto:4.1.3-6503028' testImplementation 'org.apache.commons:commons-lang3:3.12.0' diff --git a/jadx-gui/build.gradle b/jadx-gui/build.gradle index 1e7d1ec9..b75b3842 100644 --- a/jadx-gui/build.gradle +++ b/jadx-gui/build.gradle @@ -1,6 +1,6 @@ plugins { id 'application' - id 'edu.sc.seis.launch4j' version '2.4.9' + id 'edu.sc.seis.launch4j' version '2.5.0' id 'com.github.johnrengelman.shadow' version '6.1.0' } @@ -21,13 +21,13 @@ dependencies { implementation 'io.reactivex.rxjava2:rxjava:2.2.21' implementation "com.github.akarnokd:rxjava2-swing:0.3.7" - implementation 'com.android.tools.build:apksig:4.1.1' + implementation 'com.android.tools.build:apksig:4.1.3' implementation 'io.github.hqktech:jdwp:1.0' } application { applicationName = 'jadx-gui' - mainClassName = 'jadx.gui.JadxGUI' + mainClass.set('jadx.gui.JadxGUI') } applicationDistribution.with { @@ -42,12 +42,15 @@ applicationDistribution.with { jar { manifest { attributes( - "Main-Class": mainClassName, + "Main-Class": application.mainClass.get(), "Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ') ) } } +shadow { + mainClassName = application.mainClass.get() +} shadowJar { mergeServiceFiles() } @@ -64,9 +67,9 @@ startScripts { } launch4j { - mainClassName = 'jadx.gui.JadxGUI' + mainClassName = application.mainClass.get() copyConfigurable = project.tasks.shadowJar.outputs.files - jar = "lib/${project.tasks.shadowJar.archiveFileName.get()}" + jarTask = project.tasks.shadowJar icon = "${projectDir}/src/main/resources/logos/jadx-logo.ico" outfile = "jadx-gui-${version}.exe" copyright = 'Skylot' diff --git a/jadx-plugins/jadx-dex-input/build.gradle b/jadx-plugins/jadx-dex-input/build.gradle index b86a63db..8c1349b5 100644 --- a/jadx-plugins/jadx-dex-input/build.gradle +++ b/jadx-plugins/jadx-dex-input/build.gradle @@ -9,7 +9,7 @@ dependencies { implementation 'org.smali:baksmali:2.5.2' // force latest version for smali constraints { - implementation 'com.google.guava:guava:30.1-jre' + implementation 'com.google.guava:guava:30.1.1-jre' implementation 'com.beust:jcommander:1.81' } diff --git a/jadx-plugins/jadx-smali-input/build.gradle b/jadx-plugins/jadx-smali-input/build.gradle index 07dd5928..fb3b0589 100644 --- a/jadx-plugins/jadx-smali-input/build.gradle +++ b/jadx-plugins/jadx-smali-input/build.gradle @@ -12,7 +12,7 @@ dependencies { } // force latest version for smali constraints { - implementation 'com.google.guava:guava:30.1-jre' + implementation 'com.google.guava:guava:30.1.1-jre' implementation 'com.beust:jcommander:1.81' } } diff --git a/jadx-samples/build.gradle b/jadx-samples/build.gradle index 0b696316..83e79e75 100644 --- a/jadx-samples/build.gradle +++ b/jadx-samples/build.gradle @@ -27,7 +27,7 @@ task samplesJar(type: Jar, dependsOn: samplesRun) { task samplesJadxCreate(type: JavaExec, dependsOn: samplesJar) { classpath = sourceSets.main.output + configurations.runtimeClasspath - main = project(":jadx-cli").mainClassName + main = project(":jadx-cli").application.mainClass.get() args = ['-v', '-d', samplesJadxSrcDir, samplesJar.archiveFile.get()] } -- GitLab