【问题标题】:How to change default strategy for project version?如何更改项目版本的默认策略?
【发布时间】: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


    【解决方案1】:

    也许它已经解决了。类似的设置适用于version "15.0.2",但它必须直接跟随plugins 块:

    release {
      defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.SNAPSHOT
    }
    

    【讨论】:

      猜你喜欢
      • 2016-10-15
      • 2010-12-02
      • 1970-01-01
      • 2018-07-07
      • 2023-04-06
      • 2011-08-16
      • 2021-10-19
      • 2018-06-06
      • 1970-01-01
      相关资源
      最近更新 更多