我使用gradle将构建的工件上传到我们的存储库管理器(Nexus) 我正在使用以下命令行:
./gradlew --stacktrace --info uploadArchives -PnexusUsername=de -PnexusPassword=np
在build.gradle文件中,我有:
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${nexusUrl}/content/repositories/releases") {
authentication(userName: nexusUsername, password: nexusPassword)
}
}
}
}
如何从命令行覆盖默认版本?
答案 0 :(得分:0)
我找到了一种快速的方法来支持这一点
在build.gradle中,我添加并更新了uploadArchives
:
...
version = getVersion()
// Option to override Nexus version by setting env var CUSTOM_VERSION
def pomVersion = System.getenv("CUSTOM_VERSION") ?: version
...
...
uploadArchives {
repositories {
mavenDeployer {
repository(url: "${nexusUrl}/content/repositories/releases") {
authentication(userName: nexusUsername, password: nexusPassword)
}
pom.version = pomVersion
}
}
}
现在,我只需要在运行命令行之前设置 CUSTOM_VERSION 。
我希望这会有所帮助。欢迎更多选择!