问题描述
我正在尝试使用gradle6.6构建Java项目并在Eclipse 03-2020中打开jre 11.0.2。 在构建使用jrt-fs.jar中的类的项目时,我遇到编译问题。例如在开放的jre 11中的“ sun.net.www.protocol.http.Handler”。
public class Manager extends sun.net.www.protocol.https.Handler{
(package sun.net.www.protocol.https is declared in module java.base,which
does not export it)
1 error
FAILURE: Build Failed with an exception.
* What went wrong:
Execution Failed for task ':compileJava'.
> Compilation Failed; see the compiler error output for details.
以下是我的build.gradle:
apply plugin: 'java'
apply plugin: 'application'
allprojects {
apply plugin: 'java'
sourceCompatibility = '11.0.2'
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
mavenCentral()
}
dependencies {
compile filetree(dir: 'lib',include: '*.jar')
compile group: 'org.hamcrest',name: 'hamcrest-all',version: '1.3'
compile group: 'junit',name: 'junit',version: '4.10'
compile group: 'jmock',name: 'jmock',version: '1.0.1'
compile group: 'com.google.code.findbugs',name: 'findbugs',version: '1.3.9'
compile group: 'cglib',name: 'cglib',version: '2.1'
testCompile group: 'junit',version: '4.10'
}
此外,如何避免通过gradle构建测试类?
解决方法
如@ dave_thompson_085所建议,问题是由于sun.net。*软件包上的模块化限制(从JDK-1.9起)所致,因为它们是JDK内部的。以上软件包可在JDK -1.8中访问。我们需要修复代码