Set JDK home (javac path) in user's gradle.properties

流过昼夜 提交于 2019-12-03 21:33:31

In your gradle.properties:

javacPath=/home/mj/lib/jdk1.7.0_80/bin/javac

In your build.gradle

options.forkOptions.executable = project.property('javacPath')

Using a path relative to "java.home" has worked for us. Not elegant, but this does not need another setting. The reason why we need this in the first place is that we build with a JDK that's part of the working copy, not pre-installed with the Jenkins slave. We have no javac/JDK on the slave, just a JRE to run the Jenkins slave. Our gradlew in the working copy points to the JDK next to it.

compileJava {
  options.fork = true
  options.forkOptions.executable = "${System.properties['java.home']}/../bin/javac"
}

(Note: At Java run time, java.home points to the $JAVA_HOME/jre folder within the JDK. That's one below where the JAVA_HOME environment variable points to.)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!