From 816ab99ac5490177011103f20474f6f84a01abc7 Mon Sep 17 00:00:00 2001 From: Riccardo Balbo Date: Mon, 4 Nov 2019 14:29:01 +0100 Subject: [PATCH] Fix version naming. Use version-branch-SNAPSHOT for local builds, add custom version name property. --- .github/workflows/main.yml | 12 +++++----- common-android-app.gradle | 2 +- common.gradle | 8 +++---- gradle.properties | 17 +++++++------- version.gradle | 45 +++++++++++++++++++++++++++----------- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d42744dc3..8782a24e63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,7 +75,7 @@ jobs: # Build # Note: since this is crossbuild we use the buildForPlatforms filter to tell # the buildscript wich platforms it should build for. - gradle --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \ + gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildForPlatforms=LinuxArm,LinuxArmHF,LinuxArm64 -PbuildNativeProjects=true \ :jme3-bullet-native:assemble - name: Upload natives @@ -99,7 +99,7 @@ jobs: - name: Build run: | - gradle --no-daemon -PbuildNativeProjects=true \ + gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true \ :jme3-android-native:assemble \ :jme3-bullet-native-android:assemble @@ -159,7 +159,7 @@ jobs: fi # Build - gradle --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \ + gradle -PuseCommitHashAsVersionName=true --no-daemon -PbuildNativeProjects=true -Dmaven.repo.local="$PWD/dist/maven" \ build \ :jme3-bullet-native:build @@ -238,7 +238,7 @@ jobs: shell: bash run: | # Build - gradle -PskipPrebuildLibraries=true build + gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true build if [ "${{ matrix.deploy }}" = "true" ]; then @@ -247,7 +247,7 @@ jobs: sudo apt-get install -y zip # Create the zip release and the javadoc - gradle -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution + gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true mergedJavadoc createZipDistribution # We prepare the release for deploy mkdir -p ./dist/release/ @@ -255,7 +255,7 @@ jobs: # Create the maven artifacts mkdir -p ./dist/maven/ - gradle -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven" + gradle -PuseCommitHashAsVersionName=true -PskipPrebuildLibraries=true install -Dmaven.repo.local="$PWD/dist/maven" # Zip the natives into a single archive (we are going to use this to deploy native snapshots) echo "Create native zip" diff --git a/common-android-app.gradle b/common-android-app.gradle index ff5dea0b16..35d5ecaf7a 100644 --- a/common-android-app.gradle +++ b/common-android-app.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.android.application' group = 'org.jmonkeyengine' -version = jmeVersion + '-' + jmeVersionTag +version = jmeFullVersion sourceCompatibility = '1.6' diff --git a/common.gradle b/common.gradle index 9094dce96d..21ffc4d015 100644 --- a/common.gradle +++ b/common.gradle @@ -7,7 +7,7 @@ apply plugin: 'groovy' apply plugin: 'maven' group = 'org.jmonkeyengine' -version = jmePomVersion +version = jmeFullVersion sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' @@ -51,9 +51,9 @@ jar { javadoc { failOnError = false options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED - options.docTitle = "jMonkeyEngine ${jmeMainVersion} ${project.name} Javadoc" - options.windowTitle = "jMonkeyEngine ${jmeMainVersion} ${project.name} Javadoc" - options.header = "jMonkeyEngine ${jmeMainVersion} ${project.name}" + options.docTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc" + options.windowTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc" + options.header = "jMonkeyEngine ${jmeFullVersion} ${project.name}" options.author = "true" options.use = "true" options.charSet = "UTF-8" diff --git a/gradle.properties b/gradle.properties index 169a0e4ab2..82c99b55ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,12 @@ -# Version number: Major.Minor.Patch (e.g. 3.1.3) -jmeVersion = 3.3.0 -# Version for application and settings folder (no spaces!) -jmeMainVersion = 3.3 -# Version label: SNAPSHOT, alpha1, beta1, stable -jmeVersionTag = SNAPSHOT -# Increment this each time jmeVersionTag changes but jmeVersion stays the same -jmeVersionTagID = 6 +# Version number: Major.Minor (e.g. 3.3) +jmeVersion = 3.3 + +# Leave empty to autogenerate +# (use -PjmeVersionName="myVersion" from commandline to specify a custom version name ) +jmeVersionName = + +# If true, the version name will contain the commit hash +useCommitHashAsVersionName = false # specify if JavaDoc should be built buildJavaDoc = true diff --git a/version.gradle b/version.gradle index 5d5b1311fd..80972003af 100644 --- a/version.gradle +++ b/version.gradle @@ -18,8 +18,8 @@ ext { jmeShortGitHash = "" jmeBuildDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) jmeBranchName = "unknown" - jmeFullVersion = "${jmeVersion}-UNKNOWN" - jmePomVersion = "${jmeVersion}-UNKNOWN" + jmeFullVersion = "${jmeVersion}-SNAPSHOT" + jmeVersionTag="SNAPSHOT" } task configureVersionInfo { @@ -32,19 +32,38 @@ task configureVersionInfo { 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 + 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 } - logger.warn("Full Version: ${jmeFullVersion}") - logger.warn("POM Version: ${jmePomVersion}") + + 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 + ". " + \