Gradle和Eclipse-“..:DependentProject”不支持settings.gradle? [英] Gradle and Eclipse- "..:DependentProject" not supported in settings.gradle?

查看:212
本文介绍了Gradle和Eclipse-“..:DependentProject”不支持settings.gradle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入兄弟项目 tom-commons 。我的项目 budget_assistant 需要 tom-commons 作为依赖项,它们都位于同一工作区文件夹中,而不是嵌套。它在Intellij IDEA和命令行中工作正常。但Eclipse似乎并不喜欢它。





我不认为它喜欢..相对路径,Eclipse必须认为它是嵌套在我的项目下的一个文件夹。有没有办法将这个依赖关系解析为绝对URL?



这是我的 settings.gradle

  include':..:tom-commons'

这里是我的 build.gradle

 存储库{
mavenCentral()
}

apply plugin:'java'
apply plugin:'eclipse'
apply plugin:'idea'

dependencies {
编译组:'com.google.guava',名称:'guava',版本:'18 .0'
编译'org.xerial:sqlite -jdbc:3.8.7'
编译'net .jcip:jcip-annotations:1.0'
compile'joda-time:joda-time:2.7'
compile project(':..:tom-commons')
}

sourceSets {
main.java.srcDirsrc / main / java
}

jar {
from configurations.compile.collect {entry - > zipTree(entry)}
}


解决方案

问题在于你隐式地创建了一个名为:..的项目,并且Gradle工具API直接在其项目模型中将其反映为名为..的EclipseProject。但。 ..不是Eclipse工作区中导致异常的项目的有效名称。



从某种意义上说,我仍然认为这是一个错误。因为我们可以将一些责任归咎于Gradle tooling API返回非法的东西;并且更加优雅地处理这些'垃圾'数据的工具。



但是,我认为你不想要一个:..项目。相反,你只是想要一个:ChildA和:ChildB项目,它们是:的直接子项目(根据项目层次结构),但根据它们驻留在磁盘上的位置而定位为兄弟姐妹。



这种布局最容易用'includeFlat'完成(参见

在settings.gradle中:

<$ p

在settings.gradle中使用nofollow> Gradle文档) $ p $ includeFlat'ChildA','ChildB'

在build.gradle将子项称为:ChildA和:ChildB,例如:

 依赖关系{
compile project(': ChildA')
编译项目(':ChildB')
}

请参阅我的在github上更改您的示例

I am trying to import a sibling project tom-commons. My project budget_assistant needs tom-commons as a dependency, and they are both in the same workspace folder, not nested. It works fine in Intellij IDEA and the command line. But Eclipse does not seem to like it.

I don't think it is liking the ".." relative path and Eclipse must think it is a folder nested under my project. Is there a way to resolve this dependency into an absolute URL?

Here is my settings.gradle

include ':..:tom-commons'

And here is my build.gradle

repositories {
    mavenCentral()
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'

dependencies {
    compile group: 'com.google.guava', name: 'guava', version: '18.0'
    compile 'org.xerial:sqlite-jdbc:3.8.7'
    compile 'net.jcip:jcip-annotations:1.0'
    compile 'joda-time:joda-time:2.7'
    compile project(':..:tom-commons')
}

sourceSets {
    main.java.srcDir "src/main/java"
}

jar { 
    from configurations.compile.collect { entry -> zipTree(entry) }
}

解决方案

The problem is that you are implicitly creating a project called ":.." and the Gradle tooling API directly reflects that in its project model as an "EclipseProject" who's name is "..". But. ".." is not a valid name for a project in an Eclipse workspace which causes the exception.

I still think this is a bug, in a sense. As we can put some blame on both Gradle tooling API for returning something illegal; and the tooling for not handling this 'junk' data more gracefully.

But really, I think you do not want a ":.." project. Rather you just want a ":ChildA" and ":ChildB" project which are direct children of ":" (in terms of project hierarchy), but are located as siblings in terms of where they reside on disk.

This kind of layout is most easily accomplished with 'includeFlat' (see Gradle docs) in settings.gradle.

In settings.gradle:

includeFlat 'ChildA','ChildB'

In build.gradle refer to children as ":ChildA" and ":ChildB" e.g:

dependencies {
    compile project(':ChildA')
    compile project(':ChildB')
}

See my changes to your sample on github.

这篇关于Gradle和Eclipse-“..:DependentProject”不支持settings.gradle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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