gpt4 book ai didi

gradle - 如何在gradle中参数化依赖版本?

转载 作者:行者123 更新时间:2023-12-03 04:00:47 25 4
gpt4 key购买 nike

假设我在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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com