本项目为 Gradle 插件,用于build
与release
时自动根据 Git 推算版本号(遵循semver规范)
详细说明请查看在线文档
plugins {
id 'com.ecplugin.gradle.plugin.version' version '<version>'
}
执行 gradle build
或者 gradle release
可见推算版本
11:54:14: Executing 'build'...
reckon version: 0.0.3 -> 0.0.4-alpha
# git
git@gitee.com=username:password@https://gitee.com/xxx/
git@github.com=username:password@https://github.com/xxx/
- 若用户名或密码包含
@
或者:
,前面增加\\
。如:git@gitee.com=paul\\@gmail.com:pwd\\:111@https://gitee.com/xxx/
- Github 需使用 token 方式,用户名固定为
PRIVATE-TOKEN
,密码为 token 。如:git@github.com=PRIVATE-TOKEN:your_token@https://github.com/xxx/
参数 | 说明 |
---|---|
branches | Git分支与版本号Stage 对应关系 |
branchesReleaseMergeInto | 发布时自动合并新内容的分支 |
默认配置:
reckonVersion {
// Git分支与版本号Stage 对应关系
branches.empty()
.branch(['main', 'master'], 'rc')
.branch('test', 'beta', 'beta')
.branch('release/**', 'rc')
.branch('hotfix/**', 'rc')
.branch('**', 'alpha', 'alpha')
// 发布时自动合并新内容的分支
branchesReleaseMergeInto = ['main', 'master', 'test', 'develop/**']
}
- 若插件不生效,检查
build.gradle
是否设置了version
属性。将version
移除或设置为auto
group = 'com.xxx.xxx'
version = 'auto'
- 插件已发布至 Gradle Plugin Portal ,如提示下载失败,在
settings.gradle
增加配置如下:
pluginManagement {
repositories {
gradlePluginPortal()
...
}
}
...