Gradle compileJava task warning: [options] bootstrap class path not set in conjunction with -source 1.6

后端 未结 4 1449
轮回少年
轮回少年 2020-12-06 09:20

Below is the content of the build.gradle file:

apply plugin: \'java\'

archivesBaseName    = \'foo-bar\'
version             = \'1.0\'
sourc         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 09:40

    See the javac docs on cross compilation for details but basically it means you can compile against jdk classes that don't exist, or were different, on your target version. For example perhaps you use java.util.Deque but are targeting jdk5.

    I don't believe gradle has built in support for setting this. I have found that you need to twiddle the compile task manually. For example

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

    Having said all that, you appear to be building on jdk6 for java6 so I would think you can safely ignore the warning. Are you sure gradle is running under jdk6 and not 7?

提交回复
热议问题