我目前正在编辑 gradle 项目(“数据库”和“主数据”)。Masterdata 依赖于数据库项目。数据库发布到 Nexus 服务器,masterdata 从那里加载它作为依赖项。
masterdata的build.gradle
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")
}
}
当我在数据库项目中更改某些内容时,它需要完整的构建、发布等,直到我看到 masterdata 项目中的更改。在我之前工作的公司中,我们使用 maven 进行了类似的设置。在那里,我立即看到了依赖项的变化,而没有先发布它们。这也可以用gradle吗?也许通过多项目构建?
基本上,.classpath 中缺少以下条目:
<classpathentry combineaccessrules="false" kind="src" path="/database"/>
有没有办法自动生成它。
更新:作为一种解决方法,我将条目手动添加到 .classpath