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-excelant | |
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-excelant')
-rw-r--r-- | poi-excelant/build.gradle | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/poi-excelant/build.gradle b/poi-excelant/build.gradle index 684eef4ee2..ecd8ed5f07 100644 --- a/poi-excelant/build.gradle +++ b/poi-excelant/build.gradle @@ -23,12 +23,12 @@ configurations { sourceSets { main { - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { output.dir(JAVA9_OUT, builtBy: 'cacheJava9') } } test { - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { output.dir(TEST9_OUT, builtBy: 'cacheTest9') } } @@ -69,8 +69,10 @@ final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlfor task compileJava9(type: JavaCompile) { dependsOn 'compileJava', ':poi-ooxml:jar', ':poi-scratchpad:jar' - 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() @@ -78,6 +80,10 @@ task compileJava9(type: JavaCompile) { '--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}", '--module-path', files(MAIN_MODULE_PATH).asPath ] + + onlyIf { + jdkVersion > 8 + } } task cacheJava9(type: Copy) { @@ -90,8 +96,10 @@ task cacheJava9(type: Copy) { task compileTest9(type: JavaCompile) { dependsOn 'compileTestJava', ':poi-ooxml:jar', ':poi-scratchpad:jar' - sourceCompatibility = 9 - targetCompatibility = 9 + javaCompiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(jdkVersion) + if (jdkVendor != '') vendor = JvmVendorSpec.matching(jdkVendor) + } destinationDirectory = file(TEST9_OUT + VERSIONS9) source = file(TEST9_SRC) options.compilerArgs = [ @@ -99,6 +107,10 @@ task compileTest9(type: JavaCompile) { '--module-path', files(TEST_MODULE_PATH).asPath ] classpath = files() + + onlyIf { + jdkVersion > 8 + } } @@ -114,7 +126,7 @@ 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' } @@ -148,7 +160,7 @@ task testJar(type: Jar, dependsOn: [ testClasses, cacheTest9 ] ) { // ignore second module-info.class from main duplicatesStrategy = 'exclude' - if (JavaVersion.current() == JavaVersion.VERSION_1_8) { + if (jdkVersion == 8) { into('META-INF/versions/9') { from TEST9_SRC include '*.class' } @@ -172,7 +184,7 @@ test { jvmArgs += [ "-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}", ] - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { jvmArgs += [ '--add-modules', MODULE_NAME, '--module-path', '../build/dist/maven/poi-excelant-tests' + File.pathSeparator + files(TEST_MODULE_PATH).asPath, |