【发布时间】:2015-03-29 00:36:47
【问题描述】:
我正在将一个项目迁移到 gradle 以解决依赖关系,生成 eclipse 项目并构建项目,但我对 eclipse 项目的某些依赖项的版本有问题。这是项目的 build.gradle。这是一个带有子项目的 EAR。
apply plugin: 'ear'
def eclipseJbossName = 'org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 6.x Runtime'
def defaultEarConfig = rootDir.getAbsolutePath() + '/ear.gradle'
allprojects {
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
eclipse {
classpath {
containers eclipseJbossName
}
}
repositories {
maven {
name = "mvnrepository"
url = "http://mvnrepository.com/"
}
mavenCentral()
maven {
name = 'jboss'
url = 'http://repository.jboss.org/nexus/content/groups/public/'
}
}
}
subprojects {
configurations {
provided
}
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceSets {
main {
compileClasspath += configurations.provided
compileClasspath += configurations.compile
compileClasspath += configurations.runtime
}
}
}
dependencies {
deploy (project(path: 'anEJB')) {
transitive = false
}
deploy (project(path: 'anotherEJB')) {
transitive = false
}
deploy (project(path: 'aWAR', configuration: 'archives')) {
transitive = false
}
earlib ('commons-beanutils:commons-beanutils:1.6') {
transitive = false
}
//lots of other dependencies and all with transitive=false
}
//configuration of my subprojects
当我调用gradle ear 时,它会正确构建并生成我的工件。在 EAR 根目录内的 lib 目录中,有我所有的 earlib 及其正确版本。当我调用gradle cleanEclipse eclipse 时,它会正确生成我的项目,但是当我在 eclipse 中看到构建路径时,它使用的 commons beanutils 版本不正确。它使用的是 1.8 版本。我的所有依赖项都没有发生这种情况,但还有其他人有这个问题。我已经竭尽全力不解决传递依赖关系。
【问题讨论】:
-
抱歉,我无法重现您的问题。也许你可以为它写一个简短的复制器?您使用哪个版本的 Gradle?
-
对我来说它适用于 Gradle 2.1 ...抱歉 ...
标签: java eclipse maven gradle ear