saxonVersion = '11.2'
apiGuardianVersion = '1.1.2'
+ jdkVersion = (project.properties['jdkVersion'] ?: '8') as int
+ // see https://github.com/gradle/gradle/blob/master/subprojects/jvm-services/src/main/java/org/gradle/internal/jvm/inspection/JvmVendor.java
+ jdkVendor = (project.properties['jdkVendor'] ?: '') as String
+
JAVA9_SRC = 'src/main/java9'
JAVA9_OUT = "${buildDir}/classes/java9/main/"
TEST9_SRC = 'src/test/java9'
options.incremental = true
onlyIf {
- (name != "compileJava9" && name != "compileTest9") || JavaVersion.current() != JavaVersion.VERSION_1_8
+ (name != "compileJava9" && name != "compileTest9") // || jdkVersion > 8
}
}
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
-
repositories {
mavenCentral()
maven {
}
java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(jdkVersion))
+ if (jdkVendor != '') vendor.set(JvmVendorSpec.matching(jdkVendor))
+ }
withJavadocJar()
withSourcesJar()
}
javadoc {
failOnError = true
maxMemory = "1024M"
+ javadocTool = javaToolchains.javadocToolFor {
+ languageVersion = JavaLanguageVersion.of(11)
+ }
+
doFirst {
options {
- if (JavaVersion.current().isJava9Compatible()) {
- addBooleanOption('html5', true)
- }
+ addBooleanOption('html5', true)
addBooleanOption('Xdoclint:all,-missing', true)
links 'https://poi.apache.org/apidocs/dev/'
links 'https://docs.oracle.com/javase/8/docs/api/'
junitXml.required = true
}
+ javaLauncher = javaToolchains.launcherFor {
+ languageVersion.set(JavaLanguageVersion.of(jdkVersion))
+ if (jdkVendor != '') vendor.set(JvmVendorSpec.matching(jdkVendor))
+ }
+
// Exclude some tests that are not actually tests or do not run cleanly on purpose
exclude '**/BaseTestBorderStyle.class'
exclude '**/BaseTestCellUtil.class'
systemProperties['java.locale.providers'] = 'JRE,CLDR'
doFirst {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
// some options were removed in JDK 18
- if (JavaVersion.current().ordinal() < JavaVersion.VERSION_18.ordinal()) {
+ if (jdkVersion < 18) {
jvmArgs += [
'--illegal-access=warn',
]
- } else {
- System.out.println("Configuring for JDK 18 or higher")
}
jvmArgs += [
ignoreFailures = false
suppressAnnotations = [ 'org.apache.poi.util.SuppressForbidden' ]
// forbiddenapis bundled signatures max supported version is 14
- targetCompatibility = (JavaVersion.VERSION_14.isCompatibleWith(JavaVersion.current()) ? JavaVersion.current() : JavaVersion.VERSION_14)
+ // targetCompatibility = (JavaVersion.VERSION_14.isCompatibleWith(JavaVersion.current()) ? JavaVersion.current() : JavaVersion.VERSION_14)
}
forbiddenApisMain {
def defaultSlaves = '(ubuntu)&&!beam&&!cloud-slave&&!H29'
def jdkMapping = [
- '1.8': 'jdk_1.8_latest',
- '1.10': 'jdk_10_latest',
- '1.11': 'jdk_11_latest',
- '1.12': 'jdk_12_latest',
- '1.13': 'jdk_13_latest',
- '1.14': 'jdk_14_latest',
- '1.15': 'jdk_15_latest',
- '1.16': 'jdk_16_latest',
- '1.17': 'jdk_17_latest',
- '1.18': 'jdk_18_latest',
- 'OpenJDK 1.8': 'adoptopenjdk_hotspot_8u282',
- 'IBMJDK': 'ibmjdk_1.8.0_261',
+ '1.8': [ jenkinsJdk: 'jdk_1.8_latest', jdkVersion: 8, jdkVendor: 'oracle' ],
+ '1.10': [ jenkinsJdk: 'jdk_10_latest', jdkVersion: 10, jdkVendor: 'oracle' ],
+ '1.11': [ jenkinsJdk: 'jdk_11_latest', jdkVersion: 11, jdkVendor: 'oracle' ],
+ '1.12': [ jenkinsJdk: 'jdk_12_latest', jdkVersion: 12, jdkVendor: '' ],
+ '1.13': [ jenkinsJdk: 'jdk_13_latest', jdkVersion: 13, jdkVendor: '' ],
+ '1.14': [ jenkinsJdk: 'jdk_14_latest', jdkVersion: 14, jdkVendor: '' ],
+ '1.15': [ jenkinsJdk: 'jdk_15_latest', jdkVersion: 15, jdkVendor: '' ],
+ '1.16': [ jenkinsJdk: 'jdk_16_latest', jdkVersion: 16, jdkVendor: '' ],
+ '1.17': [ jenkinsJdk: 'jdk_17_latest', jdkVersion: 17, jdkVendor: '' ],
+ '1.18': [ jenkinsJdk: 'jdk_18_latest', jdkVersion: 18, jdkVendor: '' ],
+ 'OpenJDK 1.8': [ jenkinsJdk: 'adoptopenjdk_hotspot_8u282', jdkVersion: 8, jdkVendor: 'adoptopenjdk' ],
+ 'IBMJDK': [ jenkinsJdk: 'ibmjdk_1.8.0_261', jdkVersion: 8, jdkVendor: 'ibm' ]
]
static def shellEx(def context, String cmd, def poijob) {
}
}
}
- jdk(jdkMapping.get(jdkKey))
+ jdk(jdkMapping.get(jdkKey).jenkinsJdk)
scm {
if (poijob.githubpr) {
git {
switches('-Dsonar.organization=apache')
switches('-Dsonar.projectKey=poi-parent')
switches('-Dsonar.host.url=https://sonarcloud.io')
+ switches('-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}')
+ if (jdkMapping.get(jdkKey).jdkVendor != '') {
+ switches('-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}')
+ }
tasks('clean')
tasks('check')
tasks('jacocoTestReport')
if (poijob.saxonTest) {
switches('-Psaxon.test=true')
}
+ switches('-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}')
+ if (jdkMapping.get(jdkKey).jdkVendor != '') {
+ switches('-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}')
+ }
}
} else {
ant {
}
}
}
- jdk(jdkMapping.get(jdkKey))
+ jdk(jdkMapping.get(jdkKey).jenkinsJdk)
scm {
svn(xmlbeansSvnBase) { svnNode ->
svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
switches('-Dsonar.organization=apache')
switches('-Dsonar.projectKey=apache_xmlbeans')
switches('-Dsonar.host.url=https://sonarcloud.io')
+ switches('-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}')
+ if (jdkMapping.get(jdkKey).jdkVendor != '') {
+ switches('-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}')
+ }
}
tasks('clean')
tasks('jenkins')
sourceSets {
main {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
}
}
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()
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
'--module-path', files(MODULE_COMPILE_PATH).asPath
]
+
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
task cacheJava9(type: Copy) {
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'
}
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')
}
}
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()
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
'--module-path', files(MAIN_MODULE_PATH).asPath
]
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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 = [
'--module-path', files(TEST_MODULE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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'
}
// 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'
}
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,
sourceSets {
test {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(TEST9_OUT, builtBy: 'cacheTest9')
}
if (IBMVM) {
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 = [
'--module-path', files(MODULE_COMPILE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
// 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'
}
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,
// TypeSystemHolder.class is in the resources
output.dir(BEANS_RES, builtBy: 'generate_beans')
compileClasspath += files(BEANS_RES)
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
}
java {
compileJava {
dependsOn 'generate_beans'
+ options.fork = true
+ options.forkOptions.jvmArgs << '-Xmx2G'
}
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()
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.asPath}",
'--module-path', files(MAIN_MODULE_PATH).asPath
]
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
task cacheJava9(type: Copy) {
jar {
dependsOn 'sourceJar'
- if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
+ if (jdkVersion == 8) {
into('META-INF/versions/9') {
from JAVA9_SRC include '*.class'
}
sourceSets {
main {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
}
}
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()
'--module-path', sourceSets.main.compileClasspath.asPath
]
}
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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'
}
sourceSets {
main {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
}
compileClasspath += files(BEANS_RES)
java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(jdkVersion))
+ if (jdkVendor != '') vendor.set(JvmVendorSpec.matching(jdkVendor))
+ }
+}
+
+compileJava {
+ dependsOn 'compileOoxmlLite'
+ options.fork = true
+ options.forkOptions.jvmArgs << '-Xmx2G'
}
processResources.dependsOn 'compileOoxmlLite'
-compileJava.dependsOn 'compileOoxmlLite'
sourcesJar.dependsOn 'compileOoxmlLite'
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()
'--module-path', files(MAIN_MODULE_PATH).asPath
]
}
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
task cacheJava9(type: Copy, dependsOn: 'compileJava9') {
}
}
- if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
+ if (jdkVersion == 8) {
into('META-INF/versions/9') {
from JAVA9_SRC include '*.class'
}
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'
}
}
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')
}
}
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'
}
}
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'
}
}
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'
}
}
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()
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
'--module-path', files(MAIN_MODULE_PATH).asPath
]
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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 = [
'--module-path', files(TEST_MODULE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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'
}
// 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'
}
"-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,
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')
}
}
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()
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
'--module-path', files(MAIN_MODULE_PATH).asPath
]
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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 = [
'--module-path', files(TEST_MODULE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
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'
}
// 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'
}
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,
sourceSets {
main {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
}
java {
}
}
test {
- if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
+ if (jdkVersion > 8) {
output.dir(TEST9_OUT, builtBy: 'cacheTest9')
}
}
task compileJava9(type: JavaCompile) {
dependsOn 'compileJava'
- sourceCompatibility = 9
- targetCompatibility = 9
+ javaCompiler = javaToolchains.compilerFor {
+ languageVersion = JavaLanguageVersion.of(11)
+ }
destinationDirectory = file(JAVA9_OUT + VERSIONS9)
source = file(JAVA9_SRC)
classpath = files()
task compileTest9(type: JavaCompile) {
dependsOn 'compileTestJava'
- 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 = [
'--module-path', files(MODULE_PATH).asPath
]
classpath = files()
+
+ onlyIf {
+ jdkVersion > 8
+ }
}
jar {
dependsOn cacheJava9
- if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
+ if (jdkVersion == 8) {
into('META-INF/versions/9') {
from JAVA9_SRC include '*.class'
}
// 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'
}
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-tests' + File.pathSeparator + files(MODULE_PATH).asPath,