|
|
|
|
|
|
|
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}-UNKNOWN"
|
|
|
|
jmePomVersion = "${jmeVersion}-UNKNOWN"
|
|
|
|
}
|
|
|
|
|
|
|
|
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 (jmeGitTag != null) {
|
|
|
|
jmeGitTag = jmeGitTag.name
|
|
|
|
jmeFullVersion = jmeGitTag
|
|
|
|
jmePomVersion = jmeGitTag
|
|
|
|
} else if(jmeGitHash!=null&&!jmeGitHash.equals("")){
|
|
|
|
jmeFullVersion = jmeGitHash
|
|
|
|
jmePomVersion = jmeGitHash
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.warn("Full Version: ${jmeFullVersion}")
|
|
|
|
logger.warn("POM Version: ${jmePomVersion}")
|
|
|
|
} catch (ex) {
|
|
|
|
// Failed to get repo info
|
|
|
|
logger.warn("Failed to get repository info: " + ex.message + ". " + \
|
|
|
|
"Only partial build info will be generated.")
|
|
|
|
}
|
|
|
|
}
|