我目前处于编辑gradle项目(“数据库”&“masterdata”)的情况。 Masterdata取决于数据库项目。将数据库发布到Nexus服务器,并将其作为依赖项加载到masterdata中。在eclipse中缺少项目依赖关系
masterdata
import org.gradle.plugins.ide.eclipse.model.SourceFolder
apply plugin: "java"
apply plugin: "eclipse"
sourceCompatibility = 1.7
version = '0.1-SNAPSHOT'
group = "net.example"
def nexusHost = "http://nexus:8081"
repositories {
logger.lifecycle("Configuration: Repositories")
maven {
url nexusHost + "/nexus/content/groups/public"
}
}
dependencies {
logger.lifecycle("Configuration: Dependencies")
compile 'net.example:database:0.1-SNAPSHOT' // project where the changes happen
compile 'com.google.guava:guava:14.0.1'
testCompile 'ch.qos.logback:logback-classic:1.0.13'
testCompile 'org.testng:testng:6.8.5'
testCompile 'org.dbunit:dbunit:2.4.9'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'org.easytesting:fest-assert-core:2.0M10'
testCompile 'org.hsqldb:hsqldb:2.2.9'
}
eclipse.classpath.file {
beforeMerged { classpath ->
classpath.entries.clear()
logger.lifecycle("Classpath entries cleared")
}
whenMerged { cp ->
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/main/") }*.output = "bin/main"
cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/test/") }*.output = "bin/test"
cp.entries.removeAll { it.kind == "output" }
logger.lifecycle("Classpath entries modified")
}
}
当我改变它需要一个完整的构建数据库项目的东西的的build.gradle,发布等,直到我看到masterdata项目的变化。在我以前工作过的公司里,我们用maven做了类似的设置。在那里,我立即看到依赖关系的变化,而不是首先发布它们。这也可以用gradle吗?也许通过多项目构建?
基本上由下列项从丢失的.classpath:
<classpathentry combineaccessrules="false" kind="src" path="/database"/>
是否有办法来自动它的产生。
更新:作为一种变通方法我手动添加条目到的.classpath
我收到以下错误: 您无法从抽象接口'org.gradle.api.artifacts.ProjectDependency'中创建实例。 –
@Bernard我有同样的问题,它有助于添加'import org.gradle.plugins.ide.eclipse.model。ProjectDependency'放在我的.gradle文件的顶部,并添加'apply plugin:'eclipse''。 – zpon