【发布时间】:2019-06-08 16:03:00
【问题描述】:
我需要使用 project.version 构建我的工件,等于快照基于 git 的版本。
例如clean build或idea build之后的默认版本:
0.2-dev.#hash
我需要:1.1-SNAPSHOT,其中 1.1 来自 git 标签,就像我运行 snapshot 任务时一样
我试图改变ReleasePluginExtension.groovy:
release {
defaultVersionStrategy = Strategies.SNAPSHOT
}
和
release {
versionStrategy(Strategies.SNAPSHOT)
}
没用
我目前的解决方法是通过 build.gradle 在内部设置 project.version,就像在库代码中一样 - 创建快照策略对象并调用 #version() 方法:
release {
def gitRoot = project.hasProperty('git.root') ? project.property('git.root') : project.rootProject.projectDir
def git = Grgit.open(dir: gitRoot)
project.version = Strategies.SNAPSHOT.infer(project, git).version()
}
但我认为它应该可以通过 nebula-plugin 自定义。
【问题讨论】:
标签: gradle gradle-plugin netflix netflix-nebula-plugins