在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):passsy/gradle-GitVersioner开源软件地址(OpenSource Url):https://github.com/passsy/gradle-GitVersioner开源编程语言(OpenSource Language):开源软件介绍(OpenSource Introduction):Git Versioner for gradleDeprecatedDON'T USE THIS SCRIPT! It contains bugs and can't be updated (due to the fact hundreds of projects pull it directly from master). Please use
AboutVersion numbers are hard.
It was easier with SVN where the revision number got increased for every commit.
Revision ####Read the story behind on medium IdeaJust count the commits of the main branch ( This technique is often used and far better than just a SHA1 of the latest commit.
But I think it gives too much insights of the project.
Once a client knows That's why this versioner adds the project age (initial commit to latest commit) as seconds part to the revision.
By default, one year equals When working on a feature branch this versioner adds a two char identifier of the branch name and the commit count since branching.
When you are building and you have uncommited files it adds the count of the uncommited files and Reading the VersionNormal build number
On a feature branch
Build with local changes
Get itConfigure the plugin in you top level // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// ...
}
// Optional: configure the versioner
ext.gitVersioner = [
defaultBranch : "develop", // default "master"
stableBranches : ["master", "someOtherBranch"], // default [], the feature branch postfix (-dm4(6)) will not be appended on stable branches, all commits are included into the version number calculation
yearFactor : 1200, // default "1000", increasing every 8.57h
snapshotEnabled : false, // default false, the "-SNAPSHOT" postfix
localChangesCountEnabled: false, // default false, the (<commitCount>) before -SNAPSHOT
shortName: { gitVersion -> // optional closure to build a short name
// allows you to add your own short name logic
// All properties from gitVersion are available
// can be used for CI `System.getenv("BUILD_NUMBER")`
// i.e. use short sha1
return gitVersion.commit.subSequence(0, 7)
}
]
// import the script which runs the version generation
apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'
// variable `gitVersionName` can be used everywhere to get the revision name
println("versionName: $gitVersionName") // output: "versionName: 1083-dm4(6)-SNAPSHOT" Consider using this cache plugin for offline support. All inforamtion is not only available as a single // get granular information with variable `gitVersion` of type `GitVersion`
println("version: ${gitVersion.version}") // output "version: 1083"
// see all available attributes
class GitVersion {
String name;
int version;
String branchName;
String shortBranch;
int branchVersion;
int localChanges;
String commit;
} AndroidDisplay the version in your android app app android {
defaultConfig {
...
buildConfigField 'String', 'REVISION', "\"$gitVersionName\""
}
} in your @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, BuildConfig.REVISION, Toast.LENGTH_SHORT).show();
} License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论