A complete 3D game development suite written purely in Java.
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.
jmonkeyengine/version.gradle

54 lines
1.5 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}-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.")
}
}