Gradle 强制下载不同版本的依赖项,仅适用于特定的传递性依赖。

huangapple go评论67阅读模式
英文:

Gradle force download a different version only for a particular Transitive dependency

问题

I am force-downloading a dependency using the below gradle-script

implementation ('org.springframework.boot:spring-boot-starter-webflux:2.2.2.RELEASE') {
force = true
}

This dependency always brings me 3.2.13.RELEASE version of io.projectreactor:reactor-core (transitive dependency)

But i want to have 3.3.0.RELEASE of io.projectreactor:reactor-core

Below is my full build.gradle

plugins {
id 'java'
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'maven-publish'
id 'jacoco'
id 'org.sonarqube' version '2.7'
}

apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Greenwich.SR3'
mavenBom 'io.pivotal.spring.cloud:spring-cloud-services-dependencies:2.1.1.RELEASE'
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-client'

implementation 'org.springframework.boot:spring-boot-starter-webflux'

implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'

//security
implementation 'org.springframework.boot:spring-boot-starter-security'

//other
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

}

How to force download only this particular dependency in gradle ?

英文:

I am force-downloading a dependency using the below gradle-script

implementation ('org.springframework.boot:spring-boot-starter-webflux:2.2.2.RELEASE') {
		force = true
}

This dependency always brings me 3.2.13.RELEASE version of io.projectreactor:reactor-core (transitive dependency)

But i want to have 3.3.0.RELEASE of io.projectreactor:reactor-core

Below is my full build.gradle

plugins {
	id 'java'
	id 'org.springframework.boot' version '2.2.1.RELEASE'
	id 'maven-publish'
	id 'jacoco'
	id 'org.sonarqube' version '2.7'
}





apply plugin: 'io.spring.dependency-management'
dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Greenwich.SR3'
        mavenBom 'io.pivotal.spring.cloud:spring-cloud-services-dependencies:2.1.1.RELEASE'
        mavenBom  org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
    }
}


dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.security:spring-security-oauth2-client'

	implementation 'org.springframework.boot:spring-boot-starter-webflux'

	implementation 'org.springframework.boot:spring-boot-starter-web'

	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
	implementation 'io.springfox:springfox-swagger2:2.9.2'
	implementation 'io.springfox:springfox-swagger-ui:2.9.2'

	//security
	implementation 'org.springframework.boot:spring-boot-starter-security'
	

	//other
	compileOnly 'org.projectlombok:lombok'
	annotationProcessor 'org.projectlombok:lombok'

	
}

How to force download only this particular dependency in gradle ?

答案1

得分: 2

使用 resolutionStrategy 如下:

configurations.all {
    resolutionStrategy {
        force 'io.projectreactor:reactor-core:3.3.0.RELEASE'
    }
}
英文:

Use a resolutionStrategy like:

configurations.all {
    resolutionStrategy {
        force 'io.projectreactor:reactor-core:3.3.0.RELEASE'
    }
}

huangapple
  • 本文由 发表于 2020年1月3日 23:50:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581484.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定