Gradle eclipse类路径 - 在SNAPSHOT和项目依赖关系之间切换 [英] Gradle eclipse classpath - Switching between SNAPSHOT and project dependency

查看:351
本文介绍了Gradle eclipse类路径 - 在SNAPSHOT和项目依赖关系之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Java项目中有多个模块,每个模块将SNAPSHOT jar文件发布到Nexus仓库。所有子模块都直接依赖于SNAPSHOT jar文件。



在开发过程中,我们要依靠Eclipse项目而不是SNAPSHOT jar。所以我们引入了一个在依赖关系之间切换的标志,如下所示。

  if(System.properties.'setupProject'){
编译项目(':Core')
编译项目(':Module1')
编译项目(':Module2')
} else {
compile'c​​om.test:core:0.1-SNAPSHOT'
compile' com.test:module1:0.1-SNAPSHOT'
compile'c​​om.test:module2:0.1-SNAPSHOT'
}

执行以下命令将按预期生成.classpath文件。


gradle eclipse -DsetupProject = true有没有更好的方法来做到这一点?


我们可以使用Gradle配置来实现吗?
我找不到相同的例子。

解决方案

目前来说,这是要走的路。您可以调整这一点,而不是使用System属性将项目标记为可用,您可以检查项目文件夹是否可用(项目已签出)



欢呼,
René


We have a multiple modules in our Java project and each module publishes SNAPSHOT jar files to Nexus repository. All the sub-modules are directly dependent on the SNAPSHOT jar files.

During development, we want to depend on the Eclipse project rather than SNAPSHOT jars. So we introduced a flag which switches between the dependencies as shown below.

if(System.properties.'setupProject'){
    compile project(':Core')
    compile project(':Module1')
    compile project(':Module2')
}else{
    compile 'com.test:core:0.1-SNAPSHOT'
    compile 'com.test:module1:0.1-SNAPSHOT'
    compile 'com.test:module2:0.1-SNAPSHOT'
}

Executing the following command generates the .classpath file as expected.

gradle eclipse -DsetupProject=true

Is there a better way to do this? Can we use Gradle configurations to achieve the same? I could not find good examples for the same.

解决方案

At the moment this is the way to go. You might tweak this even more and instead of using a System property to mark a project as available you can check if the project folder is available (project is checked out)

cheers, René

这篇关于Gradle eclipse类路径 - 在SNAPSHOT和项目依赖关系之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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