You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.2 KiB
72 lines
2.2 KiB
|
|
import java.text.SimpleDateFormat
|
|
import org.ajoberstar.grgit.*
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath 'org.ajoberstar:gradle-git:1.2.0'
|
|
}
|
|
}
|
|
|
|
ext {
|
|
jmeRevision = 0
|
|
jmeGitHash = ""
|
|
jmeGitTag = ""
|
|
jmeShortGitHash = ""
|
|
jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date())
|
|
jmeBranchName = "unknown"
|
|
jmeFullVersion = "${jmeVersion}-SNAPSHOT"
|
|
jmeVersionTag="SNAPSHOT"
|
|
}
|
|
|
|
task configureVersionInfo {
|
|
try {
|
|
def grgit = Grgit.open(project.file('.'))
|
|
def head = grgit.head()
|
|
jmeRevision = grgit.log(includes: [head]).size()
|
|
jmeGitHash = head.id
|
|
jmeShortGitHash = head.abbreviatedId
|
|
jmeBranchName = grgit.branch.current.name
|
|
jmeGitTag = grgit.tag.list().find { it.commit == head }
|
|
|
|
if(jmeVersionName==""){
|
|
if (jmeGitTag != null) {
|
|
jmeGitTag = jmeGitTag.name
|
|
jmeFullVersion = jmeGitTag
|
|
jmeVersionTag = ""
|
|
} else {
|
|
if(useCommitHashAsVersionName=="true"&&jmeGitHash!=null&&!jmeGitHash.equals("")){
|
|
jmeFullVersion = jmeGitHash
|
|
jmeVersionTag = ""
|
|
}else{
|
|
jmeFullVersion="${jmeVersion}-";
|
|
if(jmeBranchName!="master")jmeFullVersion+="${jmeBranchName}-";
|
|
jmeFullVersion+="SNAPSHOT"
|
|
jmeVersionTag="SNAPSHOT"
|
|
}
|
|
}
|
|
}else{
|
|
jmeVersionTag=""
|
|
jmeFullVersion=jmeVersionName
|
|
}
|
|
|
|
|
|
println("Revision: ${jmeRevision}")
|
|
println("Hash: ${jmeGitHash}")
|
|
println("Short Hash: ${jmeShortGitHash}")
|
|
println("Tag: ${jmeGitTag}")
|
|
println("Build Date: ${jmeBuildDate}")
|
|
println("Build Branch: ${jmeBranchName}")
|
|
println("Use commit hash as version ${useCommitHashAsVersionName}")
|
|
println("Build Tag: ${jmeVersionTag}")
|
|
println("Build Version: ${jmeFullVersion}")
|
|
|
|
} catch (ex) {
|
|
// Failed to get repo info
|
|
logger.warn("Failed to get repository info: " + ex.message + ". " + \
|
|
"Only partial build info will be generated.")
|
|
}
|
|
}
|
|
|