我正在尝试 JDK9 (9-ea+143),需要设置--add-modules java.xml.bind
. 我努力了:
- 环境
GRADLE_OPTS="--add-modules java.xml.bind '-Dorg.gradle.jvmargs=--add-modules java.xml.bind'"
org.gradle.jvmargs=--add-modules java.xml.bind
在 gradle.properties 中设置。- 添加
test { jvmArgs '--add-modules java.xml.bind' }
到 build.gradle - 添加
tasks.withType(Test) { jvmArgs '--add-modules java.xml.bind' }
到 build.gradle - 添加
tasks.withType(JavaExec) { jvmArgs '--add-modules java.xml.bind' }
到 build.gradle
测试仍然失败。我错过了什么?
我在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