version: new versioning scheme for tags
This commit is contained in:
parent
fda40563c5
commit
c6336c0781
@ -61,7 +61,7 @@ task libDist(dependsOn: subprojects.build) << {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
|
task createZipDistribution(type:Zip,dependsOn:["dist","libDist"], description:"Package the nightly zip distribution"){
|
||||||
archiveName "jME" + jmeFullVersion + ".zip"
|
archiveName "jME" + releaseInfo.fullVersion + ".zip"
|
||||||
into("/") {
|
into("/") {
|
||||||
from {"./dist"}
|
from {"./dist"}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ apply plugin: 'java'
|
|||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
|
|
||||||
group = 'com.jme3'
|
group = 'com.jme3'
|
||||||
version = jmePomVersion
|
version = releaseInfo.pomVersion
|
||||||
|
|
||||||
sourceCompatibility = '1.6'
|
sourceCompatibility = '1.6'
|
||||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
@ -33,7 +33,7 @@ dependencies {
|
|||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Implementation-Title': 'jMonkeyEngine',
|
attributes 'Implementation-Title': 'jMonkeyEngine',
|
||||||
'Implementation-Version': jmeFullVersion
|
'Implementation-Version': releaseInfo.fullVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
jmeVersion = 3.1.0
|
jmeVersion = 3.1.0
|
||||||
# Version used for application and settings folder, no spaces!
|
# Version used for application and settings folder, no spaces!
|
||||||
jmeMainVersion = 3.1
|
jmeMainVersion = 3.1
|
||||||
# Version addition pre-alpha-svn, Stable, Beta
|
|
||||||
jmeVersionTag = SNAPSHOT
|
|
||||||
# Increment this each time jmeVersionTag changes but jmeVersion stays the same
|
# Increment this each time jmeVersionTag changes but jmeVersion stays the same
|
||||||
jmeVersionTagID = 0
|
jmeVersionTagID = 0
|
||||||
|
|
||||||
|
@ -35,16 +35,15 @@ task updateVersionPropertiesFile << {
|
|||||||
def verfile = file('src/main/resources/com/jme3/system/version.properties')
|
def verfile = file('src/main/resources/com/jme3/system/version.properties')
|
||||||
verfile.text = "# THIS IS AN AUTO-GENERATED FILE..\n" +
|
verfile.text = "# THIS IS AN AUTO-GENERATED FILE..\n" +
|
||||||
"# DO NOT MODIFY!\n" +
|
"# DO NOT MODIFY!\n" +
|
||||||
"build.date=${jmeBuildDate}\n" +
|
"build.date=${releaseInfo.buildDate}\n" +
|
||||||
"git.revision=${jmeRevision}\n" +
|
"git.revision=${releaseInfo.revision}\n" +
|
||||||
"git.branch=${jmeBranchName}\n" +
|
"git.branch=${releaseInfo.branch}\n" +
|
||||||
"git.hash=${jmeGitHash}\n" +
|
"git.hash=${releaseInfo.hash}\n" +
|
||||||
"git.hash.short=${jmeShortGitHash}\n" +
|
"git.hash.short=${releaseInfo.shortHash}\n" +
|
||||||
"git.tag=${jmeGitTag}\n" +
|
"git.tag=${releaseInfo.tag}\n" +
|
||||||
"name.full=jMonkeyEngine ${jmeFullVersion}\n" +
|
"name.full=jMonkeyEngine ${releaseInfo.fullVersion}\n" +
|
||||||
"version.full=${jmeFullVersion}\n" +
|
"version.full=${releaseInfo.fullVersion}\n" +
|
||||||
"version.number=${jmeVersion}\n" +
|
"version.number=${releaseInfo.version}\n"
|
||||||
"version.tag=${jmeVersionTag}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.dependsOn(updateVersionPropertiesFile)
|
compileJava.dependsOn(updateVersionPropertiesFile)
|
||||||
|
229
version.gradle
229
version.gradle
@ -2,29 +2,21 @@
|
|||||||
Version Info Examples
|
Version Info Examples
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
Nightly Build Snapshot
|
Nightly Build Snapshot (no git tag)
|
||||||
* Full Version: 3.1-5124
|
* Full Version: 3.1.0-5124
|
||||||
* POM Version: 3.1.0-SNAPSHOT
|
* POM Version: 3.1.0-SNAPSHOT
|
||||||
* NBM Revision: 5124
|
|
||||||
* NBM UC Suffix: nightly/3.1/plugins
|
|
||||||
|
|
||||||
Nightly Build Snapshot (PBRIsComing branch)
|
Nightly Build Snapshot (PBRIsComing branch) (no git tag)
|
||||||
* Full Version: 3.1-PBRIsComing-5124
|
* Full Version: 3.1.0-PBRIsComing-5124
|
||||||
* POM Version: 3.1.0-PBRIsComing-SNAPSHOT
|
* POM Version: 3.1.0-PBRIsComing-SNAPSHOT
|
||||||
* NBM Revision: 5124
|
|
||||||
* NBM UC Suffix: PBRIsComing-nightly/3.1/plugins
|
|
||||||
|
|
||||||
Alpha1 Release
|
Alpha1 Release (git tag: v3.1-alpha1)
|
||||||
* Full Version: 3.1-alpha1
|
* Full Version: 3.1.0-alpha1
|
||||||
* POM Version: 3.1.0-alpha1
|
* POM Version: 3.1.0-alpha1
|
||||||
* NBM Revision: 1
|
|
||||||
* NBM UC Suffix: stable/3.1/plugins
|
|
||||||
|
|
||||||
Final Release
|
Final Release (git tag: v3.1)
|
||||||
* Full Version: 3.1
|
* Full Version: 3.1.0
|
||||||
* POM Version: 3.1.0
|
* POM Version: 3.1.0
|
||||||
* NBM Revision: 5
|
|
||||||
* NBM UC Suffix: stable/3.1/plugins
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@ -35,83 +27,156 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'org.ajoberstar:gradle-git:1.2.0'
|
classpath 'org.ajoberstar:gradle-git:1.4.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
jmeRevision = 0
|
releaseInfo = null;
|
||||||
jmeNbmRevision = 0
|
}
|
||||||
jmeGitHash = ""
|
|
||||||
jmeGitTag = ""
|
enum ReleaseType {
|
||||||
jmeShortGitHash = ""
|
Unknown,
|
||||||
jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date())
|
Snapshot,
|
||||||
jmeBranchName = "unknown"
|
PreRelease,
|
||||||
jmeFullVersion = "${jmeVersion}-UNKNOWN"
|
Release;
|
||||||
jmePomVersion = "unknown"
|
}
|
||||||
jmeNbmUcSuffix = "unknown"
|
|
||||||
|
class ReleaseInfo {
|
||||||
|
|
||||||
|
String tag;
|
||||||
|
String version;
|
||||||
|
String releaseName;
|
||||||
|
ReleaseType releaseType;
|
||||||
|
String buildDate;
|
||||||
|
|
||||||
|
String branch;
|
||||||
|
String hash;
|
||||||
|
String shortHash;
|
||||||
|
int revision;
|
||||||
|
|
||||||
|
String fullVersion;
|
||||||
|
String pomVersion;
|
||||||
|
|
||||||
|
ReleaseInfo(String version, Grgit repo) {
|
||||||
|
loadBuildDate();
|
||||||
|
loadRepoInfo(version, repo);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseInfo(String version) {
|
||||||
|
loadBuildDate();
|
||||||
|
loadUnknownInfo(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
final void loadBuildDate() {
|
||||||
|
this.buildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
final void loadUnknownInfo(String version) {
|
||||||
|
this.releaseType = ReleaseType.Unknown;
|
||||||
|
this.version = version;
|
||||||
|
this.releaseName = "unknown";
|
||||||
|
this.tag = "";
|
||||||
|
this.revision = 0;
|
||||||
|
this.branch = "unknown";
|
||||||
|
this.hash = "";
|
||||||
|
this.shortHash = "";
|
||||||
|
this.fullVersion = "${version}-UNKNOWN";
|
||||||
|
this.pomVersion = "${version}-UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
|
final void loadRepoInfo(String version, Grgit repo) {
|
||||||
|
this.releaseType = ReleaseType.Snapshot;
|
||||||
|
this.version = version;
|
||||||
|
|
||||||
|
Commit head = repo.head();
|
||||||
|
this.revision = repo.log(includes:[head]).size();
|
||||||
|
this.hash = head.id;
|
||||||
|
this.shortHash = head.abbreviatedId;
|
||||||
|
this.branch = repo.branch.current.name;
|
||||||
|
|
||||||
|
Tag gitTag = repo.tag.list().find { it.commit == head }
|
||||||
|
if (gitTag != null){
|
||||||
|
this.tag = gitTag.name;
|
||||||
|
} else {
|
||||||
|
this.tag = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.env.TRAVIS_BRANCH != null) {
|
||||||
|
this.branch = System.env.TRAVIS_BRANCH
|
||||||
|
}
|
||||||
|
if (System.env.TRAVIS_TAG != null) {
|
||||||
|
this.tag = System.env.TRAVIS_TAG
|
||||||
|
}
|
||||||
|
if (System.env.TRAVIS_PULL_REQUEST != null && System.env.TRAVIS_PULL_REQUEST != "false") {
|
||||||
|
this.branch += "-pr-" + System.env.TRAVIS_PULL_REQUEST
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTagInfo(this.tag);
|
||||||
|
|
||||||
|
this.fullVersion = version;
|
||||||
|
if (this.branch != "master") {
|
||||||
|
this.fullVersion += "-${branch}";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (this.releaseType) {
|
||||||
|
case ReleaseType.Snapshot:
|
||||||
|
this.pomVersion = "${fullVersion}-SNAPSHOT";
|
||||||
|
this.fullVersion += "-${revision}";
|
||||||
|
break;
|
||||||
|
case ReleaseType.PreRelease:
|
||||||
|
this.pomVersion = "${fullVersion}-${releaseName}";
|
||||||
|
this.fullVersion += "-${releaseName}";
|
||||||
|
break;
|
||||||
|
case ReleaseType.Release:
|
||||||
|
this.pomVersion = "${fullVersion}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final void loadTagInfo(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
|
||||||
|
if (tag == null || !tag.startsWith("v")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = tag.split("-");
|
||||||
|
if (parts.length == 2) {
|
||||||
|
if (parts[0].size() < 1 || parts[1].size() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseType = ReleaseType.PreRelease;
|
||||||
|
version = parts[0].substring(1);
|
||||||
|
releaseName = parts[1];
|
||||||
|
} else if (parts.length == 1) {
|
||||||
|
if (parts[0].size() < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseType = ReleaseType.Release;
|
||||||
|
version = parts[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "tag = ${tag}, base_ver = ${baseVersion}, main_ver = ${mainVersion}, " +
|
||||||
|
"prerelease = ${prerelease}, release_name = ${releaseName}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task configureVersionInfo {
|
task configureVersionInfo {
|
||||||
try {
|
try {
|
||||||
def grgit = Grgit.open(project.file('.'))
|
def repo = Grgit.open(project.file('.'))
|
||||||
jmeRevision = grgit.log(includes:['HEAD']).size()
|
releaseInfo = new ReleaseInfo(jmeVersion, repo);
|
||||||
jmeGitHash = grgit.head().id
|
logger.warn("Full Version: ${releaseInfo.fullVersion}")
|
||||||
jmeShortGitHash = grgit.head().abbreviatedId
|
logger.warn("POM Version: ${releaseInfo.pomVersion}")
|
||||||
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) {
|
} catch (ex) {
|
||||||
// Failed to get repo info
|
// Failed to get repo info
|
||||||
logger.warn("Failed to get repository info: " + ex.message + ". " + \
|
logger.warn("Failed to get repository info: " + ex.message + ". " + \
|
||||||
"Only partial build info will be generated.")
|
"Only partial build info will be generated.")
|
||||||
|
|
||||||
|
releaseInfo = new ReleaseInfo(jmeVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user