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.
117 lines
3.4 KiB
117 lines
3.4 KiB
/*
|
|
Version Info Examples
|
|
=====================
|
|
|
|
Nightly Build Snapshot
|
|
* Full Version: 3.1-5124
|
|
* POM Version: 3.1.0-SNAPSHOT
|
|
* NBM Revision: 5124
|
|
* NBM UC Suffix: nightly/3.1/plugins
|
|
|
|
Nightly Build Snapshot (PBRIsComing branch)
|
|
* Full Version: 3.1-PBRIsComing-5124
|
|
* POM Version: 3.1.0-PBRIsComing-SNAPSHOT
|
|
* NBM Revision: 5124
|
|
* NBM UC Suffix: PBRIsComing-nightly/3.1/plugins
|
|
|
|
Alpha1 Release
|
|
* Full Version: 3.1-alpha1
|
|
* POM Version: 3.1.0-alpha1
|
|
* NBM Revision: 1
|
|
* NBM UC Suffix: stable/3.1/plugins
|
|
|
|
Final Release
|
|
* Full Version: 3.1
|
|
* POM Version: 3.1.0
|
|
* NBM Revision: 5
|
|
* NBM UC Suffix: stable/3.1/plugins
|
|
*/
|
|
|
|
import java.text.SimpleDateFormat
|
|
import org.ajoberstar.grgit.*
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath 'org.ajoberstar:gradle-git:1.2.0'
|
|
}
|
|
}
|
|
|
|
ext {
|
|
jmeRevision = 0
|
|
jmeNbmRevision = 0
|
|
jmeGitHash = ""
|
|
jmeGitTag = ""
|
|
jmeShortGitHash = ""
|
|
jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date())
|
|
jmeBranchName = "unknown"
|
|
jmeFullVersion = "${jmeVersion}-UNKNOWN"
|
|
jmePomVersion = "unknown"
|
|
jmeNbmUcSuffix = "unknown"
|
|
}
|
|
|
|
task configureVersionInfo {
|
|
try {
|
|
def grgit = Grgit.open(project.file('.'))
|
|
jmeRevision = grgit.log(includes:['HEAD']).size()
|
|
jmeGitHash = grgit.head().id
|
|
jmeShortGitHash = grgit.head().abbreviatedId
|
|
jmeBranchName = grgit.branch.current.name
|
|
jmeGitTag = grgit.describe()
|
|
if (jmeGitTag == null) jmeGitTag = ""
|
|
|
|
if (System.env.TRAVIS_BRANCH != null) {
|
|
jmeBranchName = System.env.TRAVIS_BRANCH
|
|
}
|
|
if (System.env.TRAVIS_TAG != null) {
|
|
jmeGitTag = System.env.TRAVIS_TAG
|
|
}
|
|
if (System.env.TRAVIS_PULL_REQUEST != null &&
|
|
System.env.TRAVIS_PULL_REQUEST != "false") {
|
|
jmeBranchName += "-pr-" + System.env.TRAVIS_PULL_REQUEST
|
|
}
|
|
|
|
jmeFullVersion = jmeMainVersion
|
|
jmePomVersion = jmeVersion
|
|
|
|
if (jmeBranchName != "master") {
|
|
jmeFullVersion += "-${jmeBranchName}"
|
|
jmePomVersion += "-${jmeBranchName}"
|
|
|
|
jmeNbmUcSuffix = "${jmeBranchName}-"
|
|
} else {
|
|
jmeNbmUcSuffix = ""
|
|
}
|
|
|
|
if (jmeVersionTag == "SNAPSHOT") {
|
|
jmeNbmUcSuffix += "nightly"
|
|
} else {
|
|
jmeNbmUcSuffix += "stable"
|
|
}
|
|
|
|
jmeNbmUcSuffix += "/" + jmeMainVersion + "/plugins"
|
|
|
|
if (jmeVersionTag == "SNAPSHOT") {
|
|
jmeFullVersion += "-${jmeRevision}"
|
|
jmePomVersion += "-SNAPSHOT"
|
|
jmeNbmRevision = jmeRevision
|
|
} else if (jmeVersionTag == "") {
|
|
jmeNbmRevision = jmeVersionTagID
|
|
} else {
|
|
jmeFullVersion += "-${jmeVersionTag}"
|
|
jmePomVersion += "-${jmeVersionTag}"
|
|
jmeNbmRevision = jmeVersionTagID
|
|
}
|
|
|
|
logger.warn("Full Version: ${jmeFullVersion}")
|
|
logger.warn("POM Version: ${jmePomVersion}")
|
|
logger.warn("NBM Revision: ${jmeNbmRevision}")
|
|
logger.warn("NBM UC Suffix: ${jmeNbmUcSuffix}")
|
|
} catch (ex) {
|
|
// Failed to get repo info
|
|
logger.warn("Failed to get repository info: " + ex.message + ". " + \
|
|
"Only partial build info will be generated.")
|
|
}
|
|
}
|
|
|