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/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/build.gradle')
-rw-r--r-- | poi-ooxml/build.gradle | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/poi-ooxml/build.gradle b/poi-ooxml/build.gradle index 35f51f67d0..b9097c0abf 100644 --- a/poi-ooxml/build.gradle +++ b/poi-ooxml/build.gradle @@ -20,14 +20,14 @@ import java.util.regex.Pattern configurations { runtimeClasspath { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } compileClasspath { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } @@ -39,12 +39,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') } } @@ -87,19 +87,19 @@ dependencies { renderImplementation "org.apache.xmlgraphics:batik-svggen:${batikVersion}" renderImplementation("org.apache.xmlgraphics:batik-svgrasterizer:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } renderImplementation("org.apache.xmlgraphics:batik-codec:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } renderImplementation("org.apache.xmlgraphics:batik-bridge:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } @@ -109,19 +109,19 @@ dependencies { rendersignImplementation "org.apache.xmlgraphics:batik-svggen:${batikVersion}" rendersignImplementation("org.apache.xmlgraphics:batik-svgrasterizer:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } rendersignImplementation("org.apache.xmlgraphics:batik-codec:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } rendersignImplementation("org.apache.xmlgraphics:batik-bridge:${batikVersion}") { exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } @@ -153,7 +153,7 @@ dependencies { broken("org.apache.xmlgraphics:batik-script:${batikVersion}"){ exclude group: 'xalan', module: 'xalan' - if (JavaVersion.current() != JavaVersion.VERSION_1_8) { + if (jdkVersion > 8) { exclude group: 'xml-apis', module: 'xml-apis' } } @@ -179,8 +179,10 @@ compileJava { task compileJava9(type: JavaCompile) { dependsOn 'compileJava', ':poi: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() @@ -188,6 +190,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) { @@ -200,8 +206,10 @@ task cacheJava9(type: Copy) { task compileTest9(type: JavaCompile) { dependsOn 'compileTestJava', ':poi:testJar' - 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 = [ @@ -209,6 +217,10 @@ task compileTest9(type: JavaCompile) { '--module-path', files(TEST_MODULE_PATH).asPath ] classpath = files() + + onlyIf { + jdkVersion > 8 + } } @@ -222,7 +234,7 @@ task cacheTest9(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' } @@ -242,7 +254,7 @@ task testJar(type: Jar, dependsOn: testClasses) { // 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' } @@ -321,7 +333,7 @@ test { "-XX:ErrorFile=../build/hs_err_pid%p.log", "-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-ooxml-tests' + File.pathSeparator + files(TEST_MODULE_PATH).asPath, |