plugin oxygen instalar configurar buildship java eclipse eclipse-plugin gradle

oxygen - Gradle compileJava task warning:[opciones] ruta de clase bootstrap no configurada junto con-source 1.6



instalar plugin gradle eclipse (4)

A continuación se muestra el contenido del archivo 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 }

A continuación, se muestra el resultado de ejecutar la tarea jar de Gradle:

[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] -----------------------------------------------------

A pesar de que afirma que la compilación fue exitosa, la advertencia me tiene un poco preocupado por las complicaciones en el tiempo de ejecución. ¿Cómo resuelvo esta advertencia?

Además, estoy usando Eclipse Indigo. Y tengo el compilador de Java y la ruta de compilación de mi proyecto establecidos en jdk1.6.0_35.

Si alguien necesita más información, ¡házmelo saber!

ACTUALIZAR

Navegué a Window > Preferences > Gradle y configuré "Java Home" al "Workspace JRE" jdk1.6.0_35,

Y ahora obtengo el siguiente resultado cuando ejecuto la tarea jar de Gradle,

[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] -----------------------------------------------------

¿Qué hacer?


Consulte los documentos javac en la compilación cruzada para obtener más información, pero básicamente significa que puede compilar contra las clases jdk que no existen, o que son diferentes, en su versión de destino. Por ejemplo, quizás use java.util.Deque pero tenga como objetivo jdk5.

No creo que Gradle haya incorporado soporte para configurar esto. Descubrí que necesita manipular manualmente la tarea de compilación. Por ejemplo

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 })

Habiendo dicho todo eso, parece que estás construyendo en jdk6 para java6, así que creo que puedes ignorar la advertencia. ¿Estás seguro de que Gradle se está ejecutando en jdk6 y no en 7?


La respuesta de Rudik necesita una pequeña modificación para funcionar con Gradle 2.0 y superior: La propiedad "Compilar" debe cambiarse a "JavaCompile". Ver: Después de actualizar a Gradle 2.0: No se pudo encontrar la propiedad ''Compilar'' en el proyecto raíz

Me encontré con el problema del cartel original en Android Studio 2.2.2 (JDK8) compilando para Google App Engine (Java 7). Aquí está la respuesta de Rudik modificada para corregir este escenario:

apply plugin: ''java'' sourceCompatibility = 1.7 targetCompatibility = 1.7 tasks.withType(JavaCompile) { options.bootClasspath = "$JDK7_HOME/jre/lib/rt.jar" }

Y de nuevo en gradle.properties, agregue lo que sea su ruta al JDK, por ejemplo, para Mac

JDK7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home

Gracias de nuevo a Rudik por publicar la respuesta original. Quería agregar un comentario en lugar de crear una nueva respuesta, pero no tenía suficientes puntos de reputación (aún).


La solución para definir la JVM para gradle en el nivel de espacio de trabajo no es ideal. En el caso de proyectos / construcciones múltiples en diferentes JVM, esto no se puede usar.

En Eclipse Kepler con Spring Gradle plugin (3.3.0) es posible definir la JVM para su tarea de compilación gradle (herramienta externa).

En la configuración de herramienta externa | Argumentos | Java Home puede definir qué JVM se debe usar para la compilación.


Puede arrancar la ruta de clase usando la opción bootClasspath:

apply plugin: ''java'' sourceCompatibility = 1.6 targetCompatibility = 1.6 compileJava.options.bootClasspath = "$JDK6_HOME/jre/lib/rt.jar"

Para establecer la opción bootClasspath en todas las tareas de compilación del proyecto, puede usar el método withType () en TaskContainer para encontrar todas las tareas de tipo Compilar:

apply plugin: ''java'' sourceCompatibility = 1.6 targetCompatibility = 1.6 tasks.withType(JavaCompile) { options.bootstrapClasspath = files("$JDK6_HOME/jre/lib/rt.jar") }

gradle.properties:

JDK6_HOME=C:/JAVA/jdk6

Ver la documentation para más detalles.