我如何告诉Gradle使用特定的JDK版本? [英] How do I tell Gradle to use specific JDK version?
问题描述
场景:
想要使用一个变量(定义为每个开发人员机器),它指向一个JDK的安装,它将用于构建整个应用程序/测试/ ...
我想过要有 gradle.properties
文件,定义变量。类似于
JAVA_HOME_FOR_MY_PROJECT =<我想要的JDK的路径>
我不想要的东西
- 点
JAVA_HOME
到所需的JDK
I可以忍受很多建议:
- 一个解决方案,它定义了一个系统环境变量,我可以在我的build.gradle脚本中检查
- 在gradle.properties中定义的变量
- 仅为构建上下文重写JAVA_HOME变量(类似于
使用JAVA_HOME =< ;我的特殊JDK路径定义在其他地方定义>
) - 其他我没想过的东西
问题:
我有多个JDK7可用,需要指向特殊版本(最低JDK_u版本)。
任何答案都是appr eciated,我感谢每一个提示正确的方向。
两种方式
-
在
.gradle
中的gradle.properties
目录中的HOME_DIRECTORY
设置org.gradle.java.home = / path_to_jdk_directory
- I have an application built with gradle
- The application uses JavaFX
- Use a variable (defined per developer machine) which points to an installation of a JDK which will be used for building the whole application / tests / ...
- point
JAVA_HOME
to the desired JDK - a solution that defines a system environment variable which I'm able to check in my build.gradle script
- a variable defined in gradle.properties
- overriding the JAVA_HOME variable only for the build context (something like
use JAVA_HOME=<my special JDK path defined somewhere else defined>
) - something else I didn't think about
- How to wire a variable (how ever defined, as variable in the
gradle.properties
, system environment variable, ...) to the build process? In
gradle.properties
in the.gradle
directory in yourHOME_DIRECTORY
setorg.gradle.java.home=/path_to_jdk_directory
In your
build.gradle
compileJava.options.fork = true compileJava.options.forkOptions.executable = /path_to_javac
$ li $
build.gradle
compileJava.options.fork = true
compileJava.options.forkOptions.executable = / path_to_javac
ol>
I can't figure out to get this working.
Scenario:
What I want
I thought about having the gradle.properties
file, defining the variable. Something like
JAVA_HOME_FOR_MY_PROJECT=<path to my desired JDK>
What I don't want
I could live with many suggestions:
Question:
I have more than one JDK7 available and need to point to a special version (minimum JDK_u version).
Any answer is appreciated and I'm thankful for every hint to the right direction.
Two ways
这篇关于我如何告诉Gradle使用特定的JDK版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!