Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

gradle - Gradle:根据项目自动选择GRADLE_HOME(Gradle: automatically choose GRADLE_HOME depending on the project)

At my job we use gradle, so on my laptop I have a ~/.gradle/init.d folder which contains the init scripts that define our enterprise-wide configuration, such as the URL of the local repository, docker publishing rules, checkstyle rules, etc.

(在我的工作中,我们使用gradle,因此在笔记本电脑上,我有一个~/.gradle/init.d文件夹,其中包含用于定义企业范围配置的初始化脚本,例如本地存储库的URL,docker发布规则,checkstyle规则等)

I want to use gradle for a personal project, so I don't want to use any of these init scripts.

(我想将gradle用于个人项目,所以我不想使用任何这些初始化脚本。)

Here are the ideas I have come up with so far:

(到目前为止,我提出了以下想法:)

  1. Rename ~/.gradle to ~/.gradle-work , create ~/.gradle-personal , and then symlink ~/.gradle to -work or -personal depending on what I'm doing.

    (重命名~/.gradle~/.gradle-work ,建立~/.gradle-personal ,然后符号链接~/.gradle-work-personal取决于我在做什么。)

  2. Have ~/.gradle as my personal gradle settings, and create another gradle folder ~/dev/work/.gradle with all my work init scripts.

    (将~/.gradle作为我的gradle设置,并使用我所有的工作初始化脚本创建另一个gradle文件夹~/dev/work/.gradle 。)

    Make sure $GRADLE_HOME is set to ~/dev/work/.gradle when running gradle for any work projects.

    (在为任何工作项目运行gradle时,请确保将$GRADLE_HOME设置为~/dev/work/.gradle 。)

  3. Some variant of 2 where gradle will automatically use ~/dev/work/.gradle if it detects that the project is in the ~/dev/work/ folder.

    (2的某种变体,如果gradle检测到项目在~/dev/work/文件夹中,它将自动使用~/dev/work/.gradle 。)

Option 1 feels quite clumsy.

(选项1感觉很笨拙。)

Option 2 feels very tedious to have to set or unset an environment variable whenever I want to use gradle.

(每当我要使用gradle时,必须设置或取消设置环境变量都使选项2感到非常乏味。)

Ideally I would like something like option 3 where I don't have to do any fiddling around whenever I change between personal or work projects.

(理想情况下,我希望选择3之类的东西,当我在个人或工作项目之间进行切换时,不必摆弄任何东西。)

Is this possible?

(这可能吗?)

Or is there another solution that could solve my problem?

(还是有其他解决方案可以解决我的问题?)

  ask by Tom translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...