【发布时间】:2014-10-25 00:33:15
【问题描述】:
我的 gradle.properties 文件中有一个版本属性,它提供了我正在构建的版本。我在构建中有一个名为 release 的任务,如果任务图中存在,它将上传到快照存储库。然而发生的事情是,即使我在构建任务中包含发布任务,当 uploadArchives 运行时,快照也不会附加到我的版本属性中,因此它会尝试上传到错误的存储库并失败。准备就绪时运行,但它似乎没有在uploadArchives 之前运行。谁能解释这里发生了什么?
uploadArchives {
repositories {
ivy {
credentials {
username nexusUser
password nexusPassword
}
if (version.endsWith("-SNAPSHOT")) {
url nexusSnapshotRepository
} else {
url nexusReleaseRepository
}
}
}
}
gradle.taskGraph.whenReady {taskGraph ->
if (!taskGraph.hasTask(release)) {
version = version + '-SNAPSHOT'
}
println "release task not included - version set to $version"
}
task release(){
doLast{
println "Releasing"
}
}
这与 gradle 网站上的示例非常相似,所以我看不出哪里出了问题。
http://www.gradle.org/docs/current/userguide/tutorial_using_tasks.html
【问题讨论】:
标签: gradle