mirror of
https://github.com/skylot/jadx.git
synced 2024-11-26 22:20:50 +00:00
build: allow to change java toolchain for build and tests
This commit is contained in:
parent
958ab245ae
commit
548821c4df
4
.github/workflows/build-artifacts.yml
vendored
4
.github/workflows/build-artifacts.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 11
|
||||
java-version: 21
|
||||
|
||||
- name: Set jadx version
|
||||
run: |
|
||||
@ -29,6 +29,8 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: ./gradlew dist distWin
|
||||
env:
|
||||
JADX_BUILD_JAVA_VERSION: 11
|
||||
|
||||
- name: Save bundle artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
5
.github/workflows/build-test.yml
vendored
5
.github/workflows/build-test.yml
vendored
@ -20,10 +20,13 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 11
|
||||
java-version: 21
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Build
|
||||
run: ./gradlew build dist distWin
|
||||
env:
|
||||
JADX_BUILD_JAVA_VERSION: 11
|
||||
|
||||
|
@ -15,6 +15,18 @@ val jadxVersion by extra { System.getenv("JADX_VERSION") ?: "dev" }
|
||||
println("jadx version: $jadxVersion")
|
||||
version = jadxVersion
|
||||
|
||||
val jadxBuildJavaVersion by extra { getBuildJavaVersion() }
|
||||
|
||||
fun getBuildJavaVersion(): Int? {
|
||||
val envVarName = "JADX_BUILD_JAVA_VERSION"
|
||||
val buildJavaVer = System.getenv(envVarName)?.toInt() ?: return null
|
||||
if (buildJavaVer < 11) {
|
||||
throw GradleException("'$envVarName' can't be set to lower than 11")
|
||||
}
|
||||
println("Set Java toolchain for jadx build to version '$buildJavaVer'")
|
||||
return buildJavaVer
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "checkstyle")
|
||||
|
@ -8,6 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
val jadxVersion: String by rootProject.extra
|
||||
val jadxBuildJavaVersion: Int? by rootProject.extra
|
||||
|
||||
group = "io.github.skylot"
|
||||
version = jadxVersion
|
||||
@ -32,6 +33,11 @@ repositories {
|
||||
}
|
||||
|
||||
java {
|
||||
jadxBuildJavaVersion?.let { buildJavaVer ->
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(buildJavaVer)
|
||||
}
|
||||
}
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
@ -24,10 +24,31 @@ dependencies {
|
||||
testImplementation("tools.profiler:async-profiler:3.0")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
exclude("**/tmp/*")
|
||||
val jadxTestJavaVersion = getTestJavaVersion()
|
||||
|
||||
fun getTestJavaVersion(): Int? {
|
||||
val envVarName = "JADX_TEST_JAVA_VERSION"
|
||||
val testJavaVer = System.getenv(envVarName)?.toInt() ?: return null
|
||||
val currentJavaVer = java.toolchain.languageVersion.get().asInt()
|
||||
if (testJavaVer < currentJavaVer) {
|
||||
throw GradleException("'$envVarName' can't be set to lower version than $currentJavaVer")
|
||||
}
|
||||
println("Set Java toolchain for core tests to version '$testJavaVer'")
|
||||
return testJavaVer
|
||||
}
|
||||
|
||||
tasks.named<Test>("test") {
|
||||
jadxTestJavaVersion?.let { testJavaVer ->
|
||||
javaLauncher =
|
||||
javaToolchains.launcherFor {
|
||||
languageVersion = JavaLanguageVersion.of(testJavaVer)
|
||||
}
|
||||
}
|
||||
|
||||
// disable cache to allow test's rerun,
|
||||
// because most tests are integration and depends on plugins and environment
|
||||
outputs.cacheIf { false }
|
||||
|
||||
// exclude temp tests
|
||||
exclude("**/tmp/*")
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
rootProject.name = "jadx"
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0")
|
||||
}
|
||||
|
||||
if (!JavaVersion.current().isJava11Compatible) {
|
||||
throw GradleException("Jadx requires at least Java 11 for build (current version is '${JavaVersion.current()}')")
|
||||
}
|
||||
|
||||
rootProject.name = "jadx"
|
||||
|
||||
include("jadx-core")
|
||||
include("jadx-cli")
|
||||
include("jadx-gui")
|
||||
|
Loading…
Reference in New Issue
Block a user