Gradle eclipse使用不正确的依赖版本

时间:2015-01-29 17:11:32

标签: java eclipse maven gradle ear

我正在将项目迁移到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版本。对于我的所有依赖项都没有发生这种情况,但还有其他人遇到此问题。我已经把所有这些都解决了传递依赖。

1 个答案:

答案 0 :(得分:0)

您可以使用鼠标右键单击Eclipse中的项目,然后单击属性。并选择" Java Build Path"然后点击"图书馆"标签。最后除去" Gradle Dependencies"之外的所有罐子。 &安培; " JRE系统库"。

完成。试试吧。

相关问题