diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2022-02-21 22:57:03 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2022-02-21 22:57:03 +0000 |
commit | b59dbbd0769e154b2c29bad19595904fe181fc48 (patch) | |
tree | 059552cc9eb7dd1e56ee1a994f5da95d6bea614c /poi-ooxml-lite-agent/build.gradle | |
parent | a881c381db69aeb4cf8622c57dfff247fc084c60 (diff) | |
download | poi-b59dbbd0769e154b2c29bad19595904fe181fc48.tar.gz poi-b59dbbd0769e154b2c29bad19595904fe181fc48.zip |
Use gradle toolchain to specify the jdk version and vendor, e.g.
> gradle -no-build-cache -PjdkVersion=16 -PjdkVendor=oracle clean check
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898288 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml-lite-agent/build.gradle')
-rw-r--r-- | poi-ooxml-lite-agent/build.gradle | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/poi-ooxml-lite-agent/build.gradle b/poi-ooxml-lite-agent/build.gradle index 4b17795650..d89680f47a 100644 --- a/poi-ooxml-lite-agent/build.gradle +++ b/poi-ooxml-lite-agent/build.gradle @@ -17,7 +17,7 @@ sourceSets { main { - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { output.dir(JAVA9_OUT, builtBy: 'cacheJava9') } } @@ -32,15 +32,19 @@ dependencies { final MODULE_NAME = 'org.apache.poi.ooxml_lite' java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + toolchain { + languageVersion.set(JavaLanguageVersion.of(jdkVersion)) + if (jdkVendor != '') vendor.set(JvmVendorSpec.matching(jdkVendor)) + } } task compileJava9(type: JavaCompile) { dependsOn 'compileJava' - sourceCompatibility = 9 - targetCompatibility = 9 + javaCompiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(jdkVersion) + if (jdkVendor != '') vendor = JvmVendorSpec.matching(jdkVendor) + } destinationDirectory = file(JAVA9_OUT + VERSIONS9) source = file(JAVA9_SRC) classpath = files() @@ -50,6 +54,10 @@ task compileJava9(type: JavaCompile) { '--module-path', sourceSets.main.compileClasspath.asPath ] } + + onlyIf { + jdkVersion > 8 + } } task cacheJava9(type: Copy) { @@ -62,7 +70,7 @@ task cacheJava9(type: Copy) { jar { destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}") - if (JavaVersion.current() == JavaVersion.VERSION_1_8) { + if (jdkVersion == 8) { into('META-INF/versions/9') { from JAVA9_SRC include '*.class' } |