I am trying JDK9 (9-ea+143), and need to set --add-modules java.xml.bind. I have tried:
GRADLE_OPTS="--add-modules java.xml.bind '-Dorg.gradle.jvmargs=--add-modules java.xml.bind'"org.gradle.jvmargs=--add-modules java.xml.bind in gradle.properties.test { jvmArgs '--add-modules java.xml.bind' } to build.gradletasks.withType(Test) { jvmArgs '--add-modules java.xml.bind' } to build.gradletasks.withType(JavaExec) { jvmArgs '--add-modules java.xml.bind' } to build.gradleTests still fail. What am I missing?
I have an example project in https://github.com/henrik242/gradle-jdk9-test-problem
✨ ./gradlew build
:compileJava
/foo/gradle-jdk9-test-problem/src/main/java/SomeClass.java:1: error: package javax.xml.bind does not exist
import javax.xml.bind.ValidationException;
^
/foo/gradle-jdk9-test-problem/src/main/java/SomeClass.java:5: error: cannot find symbol
public void doStuff() throws ValidationException {
^
symbol: class ValidationException
location: class SomeClass
/foo/gradle-jdk9-test-problem/src/main/java/SomeClass.java:6: error: cannot find symbol
throw new ValidationException("msg");
^
symbol: class ValidationException
location: class SomeClass
3 errors
:compileJava FAILED
It works when adding the following to build.gradle:
compileJava {
options.compilerArgs += ["--add-modules", "java.xml.bind"]
}
compileTestJava {
options.compilerArgs += ["--add-modules", "java.xml.bind"]
}
test {
jvmArgs += ["--add-modules", "java.xml.bind"]
}
Is there an easier way?
EDIT: This also works:
tasks.withType(AbstractCompile) {
options.compilerArgs += ["--add-modules", "java.xml.bind"]
}
tasks.withType(Test) {
jvmArgs += ["--add-modules", "java.xml.bind"]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With