我正在尝试使用JDK 9构建项目,因为使用--releasejavac 的参数意味着它可以为旧版本构建而无需安装相应的JDK/JRE.我需要支持Java 6,因此我先前存在的设置需要Java 6用于bootstrapClasspath,而另一个JDK 8或9用于gradle和IDE.我想取消JDK 6而仅使用9,并稍微整理一下构建.
我的新build.gradle具有以下配置:
tasks.withType(JavaCompile) {
options.compilerArgs.addAll(['--release', '6', "-Xlint"])
}
Run Code Online (Sandbox Code Playgroud)
的sourceCompatibility,targetCompatibility和bootstrapClasspath选项都没有设置,我的理解的--release说法,现在处理这个问题.
我收到以下警告:
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Run Code Online (Sandbox Code Playgroud)
我知道这些可以被抑制(它说就在那里),但我没想到会看到它们.当使用--release [7-9]这些警告构建时不存在.
对于上下文,这是旧的(现在未使用)'2x JDK'配置:
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
tasks.withType(JavaCompile) { …Run Code Online (Sandbox Code Playgroud)