aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2022-02-21 22:57:03 +0000
committerAndreas Beeker <kiwiwings@apache.org>2022-02-21 22:57:03 +0000
commitb59dbbd0769e154b2c29bad19595904fe181fc48 (patch)
tree059552cc9eb7dd1e56ee1a994f5da95d6bea614c /poi-scratchpad
parenta881c381db69aeb4cf8622c57dfff247fc084c60 (diff)
downloadpoi-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-scratchpad')
-rw-r--r--poi-scratchpad/build.gradle30
1 files changed, 21 insertions, 9 deletions
diff --git a/poi-scratchpad/build.gradle b/poi-scratchpad/build.gradle
index 8c2549643b..9f7ae5e5f7 100644
--- a/poi-scratchpad/build.gradle
+++ b/poi-scratchpad/build.gradle
@@ -24,12 +24,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')
}
}
@@ -64,8 +64,10 @@ final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path
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()
@@ -73,6 +75,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) {
@@ -85,8 +91,10 @@ task cacheJava9(type: Copy) {
task compileTest9(type: JavaCompile) {
dependsOn 'compileTestJava', ':poi: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 = [
@@ -94,6 +102,10 @@ task compileTest9(type: JavaCompile) {
'--module-path', files(TEST_MODULE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
@@ -107,7 +119,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'
}
@@ -127,7 +139,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'
}
@@ -176,7 +188,7 @@ test {
systemProperties['junit.jupiter.execution.parallel.enabled'] = 'true'
doFirst {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
jvmArgs += [
'--add-modules', MODULE_NAME,
'--module-path', '../build/dist/maven/poi-scratchpad-tests' + File.pathSeparator + files(TEST_MODULE_PATH).asPath,