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-integration | |
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-integration')
-rw-r--r-- | poi-integration/build.gradle | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/poi-integration/build.gradle b/poi-integration/build.gradle index 36345bcc56..14e7a40ba9 100644 --- a/poi-integration/build.gradle +++ b/poi-integration/build.gradle @@ -29,7 +29,7 @@ configurations { sourceSets { test { - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { output.dir(TEST9_OUT, builtBy: 'cacheTest9') } if (IBMVM) { @@ -98,15 +98,19 @@ final String OOXML_LITE_JAR = "../build/dist/maven/poi-ooxml-lite/poi-ooxml-lite final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)" 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 compileTest9(type: JavaCompile) { dependsOn 'compileTestJava', ':poi-ooxml:testJar', ':poi-scratchpad:testJar', ':poi-examples: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 = [ @@ -114,6 +118,10 @@ task compileTest9(type: JavaCompile) { '--module-path', files(MODULE_COMPILE_PATH).asPath ] classpath = files() + + onlyIf { + jdkVersion > 8 + } } @@ -141,7 +149,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' } @@ -170,7 +178,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-integration-tests' + File.pathSeparator + files(MODULE_RUNTIME_PATH).asPath, |