下面是build.gradle文件的内容:
apply plugin: 'java'
archivesBaseName = 'foo-bar'
version = '1.0'
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
sourceSets.main.resources.exclude 'foo.jks'
compileJava{
println project.sourceCompatibility
println project.targetCompatibility
println sourceCompatibility
println targetCompatibility
}
下面是运行Gradle jar任务的结果:
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] :jar
[sts] -----------------------------------------------------
1.6
1.6
1.6
1.6
:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
:processResources UP-TO-DATE
:classes
:jar
BUILD SUCCESSFUL
Total time: 1 mins 3.072 secs
[sts] -----------------------------------------------------
[sts] Build finished succesfully!
[sts] Time taken: 1 min, 3 sec
[sts] -----------------------------------------------------
虽然它声称构建是成功的,但这个警告让我有点担心运行时的复杂性。如何解决此警告?
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] :jar
[sts] -----------------------------------------------------
1.6
1.6
1.6
1.6
:compileJavawarning: java\lang\Enum.class(java\lang:Enum.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Comparable.class(java\lang:Comparable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Object.class(java\lang:Object.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\Serializable.class(java\io:Serializable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\String.class(java\lang:String.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\InputStream.class(java\io:InputStream.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStore.class(java\security:KeyStore.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\Cipher.class(javax\crypto:Cipher.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\spec\SecretKeySpec.class(javax\crypto\spec:SecretKeySpec.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\xml\bind\DatatypeConverter.class(javax\xml\bind:DatatypeConverter.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\CloneNotSupportedException.class(java\lang:CloneNotSupportedException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Class.class(java\lang:Class.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\ClassLoader.class(java\lang:ClassLoader.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStore$LoadStoreParameter.class(java\security:KeyStore$LoadStoreParameter.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\Closeable.class(java\io:Closeable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\AutoCloseable.class(java\lang:AutoCloseable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Exception.class(java\lang:Exception.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Throwable.class(java\lang:Throwable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\cert\Certificate.class(java\security\cert:Certificate.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\Key.class(java\security:Key.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\spec\KeySpec.class(java\security\spec:KeySpec.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\SecretKey.class(javax\crypto:SecretKey.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Error.class(java\lang:Error.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStoreException.class(java\security:KeyStoreException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\GeneralSecurityException.class(java\security:GeneralSecurityException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\RuntimeException.class(java\lang:RuntimeException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\IOException.class(java\io:IOException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\NoSuchAlgorithmException.class(java\security:NoSuchAlgorithmException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\cert\CertificateException.class(java\security\cert:CertificateException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\NoSuchPaddingException.class(javax\crypto:NoSuchPaddingException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\InvalidKeyException.class(java\security:InvalidKeyException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyException.class(java\security:KeyException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\nio\ByteBuffer.class(java\nio:ByteBuffer.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\IllegalBlockSizeException.class(javax\crypto:IllegalBlockSizeException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\BadPaddingException.class(javax\crypto:BadPaddingException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\StringBuilder.class(java\lang:StringBuilder.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\AbstractStringBuilder.class(java\lang:AbstractStringBuilder.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\CharSequence.class(java\lang:CharSequence.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\StringBuffer.class(java\lang:StringBuffer.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
39 warnings
:processResources UP-TO-DATE
:classes
:jar
BUILD SUCCESSFUL
Total time: 1.96 secs
[sts] -----------------------------------------------------
[sts] Build finished succesfully!
[sts] Time taken: 0 min, 1 sec
[sts] -----------------------------------------------------
做什么?
有关交叉编译的详细信息,请参阅javac文档,但它基本上意味着您可以针对目标版本中不存在或不同的jdk类进行编译。例如,您可能使用java.util.deque
,但目标是JDK5。
我不相信gradle已经建立了支持设置这个。我发现您需要手动旋转编译任务。例如:
def bootClasspathStr = "${yourJavaVersionXInstallationPath}/jre/lib/rt.jar"
project.tasks.withType(AbstractCompile, { AbstractCompile ac ->
ac.options.bootClasspath = bootClasspathStr // options is always there but not defined on AbstractCompile so going to hit it anyway
})
说了这么多,您似乎是在jdk6上为java6构建的,所以我认为您可以放心地忽略这个警告。你确定gradle是在jdk6下运行而不是在JDK7下运行吗?
我正在将我的应用程序从java 1.6升级到1.7。当我尝试使用Maven 3.2.1构建时,我的构建失败,错误消息如下: 我使用的是java 1.7 hotspot,之前我使用的是1.6 jrockit。我的应用程序是多模块的,很少有模块像往常一样编译和构建,这个模块失败了。 我已经正确地设置了java home和mvn——版本显示了以下输出: 我错过什么了吗?
我的java版本如下 之后 安装包装(“rJava”) 我尝试导入rJava包 库(rJava)错误:. onLoad在loadNamespace()中失败为'rJava',详细信息:调用:dyn.load(file, DLLpath=DLLpath,...)错误:无法加载共享对象'/home/ubuntu/R/x86_64-pc-linux-gnu-Library/3.0/rJava/libs/
我的gradle构建挂在bootRepackage任务上。我的应用程序使用Gradle 2.14 Spring BootJava Gradle插件是 下面是我在gradle日志中看到的内容。bootRepackage任务执行受阻,没有错误: 执行的Gradle命令: 我添加了调试选项,但它没有给我任何额外的信息。请告诉我任何建议。
尝试调试代码时收到的错误消息 Java HotSpot(TM)64位服务器虚拟机警告:共享仅支持引导加载程序类,因为已附加引导类路径“ 这意味着什么,我为什么要得到它,如何摆脱它?
我想用替换大于任意数字(本例中为100)的