簡體   English   中英

如何使用gradle排除傳遞依賴關系並用另一個替代

[英]How to exclude transitive dependencies with gradle and substitute it with another

我的情況與類似(JodaTime和Java版本大於1.8u60之間的錯誤)。

所以我需要的是:

  1. 升級到JodaTime版本2.8.1或更高版本。
  2. 問題是:JodaTime是我項目中的可傳遞依賴項。

它使用的構建自動化工具是gradle。 需要幫助來處理它。

buildscript:

buildscript {
    ext {
        springBootVersion = '1.2.4.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
        classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")
        classpath("org.flywaydb:flyway-gradle-plugin:3.2.1")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'spring-boot' 
apply plugin: 'io.spring.dependency-management' 
apply plugin: 'org.flywaydb.flyway'

jar {
    baseName = 'xxxx'
    version = 'alpha'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {

    compile("org.springframework.boot:spring-boot-starter-data-jpa:1.2.4.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-aop:1.2.4.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-web:1.2.4.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-freemarker:1.2.4.RELEASE")
    compile("com.amazonaws:aws-java-sdk:1.10.2")
    compile("com.stripe:stripe-java:1.33.0")
    compile("org.flywaydb:flyway-core:3.2.1")
    compile("com.jolbox:bonecp:0.8.0.RELEASE")

    runtime("org.postgresql:postgresql:9.4-1201-jdbc41")

    testCompile("org.springframework.boot:spring-boot-starter-test:1.2.4.RELEASE")
}

dependencyManagement {
    imports { 
        mavenBom "org.springframework.cloud:spring-cloud-starter-parent:1.0.2.RELEASE" 
    }
}

eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
    }
}

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

您需要在dependencies塊中更改以下代碼:

compile("com.amazonaws:aws-java-sdk:1.10.2") {
     exclude group: 'joda-time', module: 'joda-time'
}
compile("joda-time:joda-time:2.8.1")

將傳遞假設置為false,並在您的依賴項之間設置所需的軟件包,而不是將傳遞下載中的軟件包設置為依賴。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM