gradle冲突的传递依赖不被包括在内

时间:2015-08-04 19:06:51

标签: gradle

我有一个依赖项,my-project使用了两个使用不同版本的commons-lang3的依赖项,但是当我构建我的war工件时,commons-lang3未包含在工件中。可能有什么不对?

我的build.gradle看起来像是:

apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'war'

buildscript {
    repositories { 
        jcenter() 
    }
    dependencies { 
        classpath 'io.spring.gradle:dependency-management-plugin:0.3.0.RELEASE' 
    }
}

compileJava {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

configurations.all { 
    exclude group: 'commons-logging' 
}

repositories { 
    jcenter() 
    maven {
        credentials {
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }

        url "myrepo.com"
    }
}

dependencyManagement {
    imports { 
        mavenBom 'io.spring.platform:platform-bom:1.1.2.RELEASE' 
    }
}

dependencies {
    compile "my.project:my-project:1.0.0-SNAPSHOT"

    // Spring Framework
    compile 'org.springframework:spring-context'
    compile 'org.springframework:spring-web'
    compile 'org.springframework:spring-webmvc'
    compile 'org.springframework.security:spring-security-config'
    compile 'org.springframework.security:spring-security-web'

    // Jackson
    compile "com.fasterxml.jackson.core:jackson-annotations"
    compile "com.fasterxml.jackson.core:jackson-core"
    compile "com.fasterxml.jackson.core:jackson-databind"

    // Logging
    compile 'ch.qos.logback:logback-classic'
    compile 'org.slf4j:slf4j-api'
    runtime 'org.slf4j:jcl-over-slf4j'
    runtime 'org.logback-extensions:logback-ext-loggly:0.1.2'

    // Test
    testCompile 'junit:junit'
    testCompile 'org.mockito:mockito-core'
    testCompile 'org.springframework:spring-test'

    providedCompile 'javax.servlet:javax.servlet-api'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.web
        }
    }
    repositories {
        maven {
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }

            if(project.version.endsWith('-SNAPSHOT')) {
                url "myrepo.com/libs-snapshot-local"
            } else {
                url "myrepo.com/libs-release-local"
            }
        }
    }
}

task wrapper(type: Wrapper) { 
    gradleVersion = '2.4' 
}

编辑 my.project:my-project

的依赖关系图

my-project是我的同事编写的一个库项目,它依赖于另外两个包含commons-lang3的库项​​目。示例图表是

my.project:my-project:1.0.0-SNAPSHOT
+---my.project:my-dependency-1:1.0.0
|   +---org.apache.commons:commons-lang3:3.4
+---my.project:my-dependency-2:1.0.0
    +---org.apache.commons:commons-lang3:3.3.2

1 个答案:

答案 0 :(得分:0)

我将spring gradle dependency-management-plugin更新为0.5.2.RELEASE并解决了我的问题。