在用户的 gradle.properties 中设置 JDK home(javac 路径) [英] Set JDK home (javac path) in user's gradle.properties

查看:135
本文介绍了在用户的 gradle.properties 中设置 JDK home(javac 路径)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的 gradle 项目中指定 javac 的路径.我可以通过将以下内容添加到我的 build.gradle 文件中来做到这一点:

I need to specify the path to javac in my gradle project. I can do this by adding the following to my build.gradle file:

options.forkOptions.executable = '/home/mj/lib/jdk1.7.0_80/bin/javac'

问题是这个文件在我们的存储库中共享,我不希望设置被推送到那里.我试着把它放在我本地的 gradle.properties 文件中,但是没有用.同样设置 gradle.java.home 不会影响这个.我猜这是因为 gradle 将 gradle.java.home 用于 java 而不是 javac ,对吧?我也(无可救药地)尝试设置一个 gradle.jdk.home 这(不出所料)也不起作用!

The problem is that this file is shared in our repository and I do not want the setting to get pushed there. I tried putting it in my local gradle.properties file, but it didn't work. Also setting gradle.java.home does not affect this. I guess it's because gradle uses gradle.java.home for java and not for javac, right? I also (hopelessly) tried setting a gradle.jdk.home which (not surprisingly) didn't work either!

是否有项目之外的地方包含在 build.gradle 中?

Is there any place outside the project that is included in build.gradle?

推荐答案

在你的 gradle.properties 中:

In your gradle.properties:

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

在你的 build.gradle

In your build.gradle

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

这篇关于在用户的 gradle.properties 中设置 JDK home(javac 路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆