假设我在gradle构建中有一组依赖项:
dependencies {
compile "org.springframework:spring-core:4.3.7.RELEASE"
compile "org.springframework:spring-context:4.3.7.RELEASE"
compile "org.springframework:spring-webmvc:4.3.7.RELEASE"
compile "org.springframework:spring-web :4.3.7.RELEASE"
...
}
假设有新版本的
5.0.0.RELEASE
出现了。我不想在build.gradle
中编辑每个依赖项。有什么办法可以在此文件中设置一个变量,以用于所有依赖项?换句话说,我只会修改此变量的值,而不会修改所有依赖项。
最佳答案
您可以例如尝试:
apply plugin: 'java'
repositories {
mavenCentral()
}
ext.ver = "4.3.7.RELEASE"
dependencies {
compile "org.springframework:spring-core:$ver"
compile "org.springframework:spring-context:$ver"
compile "org.springframework:spring-webmvc:$ver"
compile "org.springframework:spring-web:$ver"
}
关于gradle - 如何在gradle中参数化依赖版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42971504/