Просмотр исходного кода

Fix version naming. Use version-branch-SNAPSHOT for local builds, add custom version name property.

Riccardo Balbo 5 лет назад
Родитель
Сommit
816ab99ac5
5 измененных файлов с 52 добавлено и 32 удалено
  1. 6 6
      .github/workflows/main.yml
  2. 1 1
      common-android-app.gradle
  3. 4 4
      common.gradle
  4. 9 8
      gradle.properties
  5. 32 13
      version.gradle

+ 6 - 6
.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"

+ 1 - 1
common-android-app.gradle

@@ -1,7 +1,7 @@
 apply plugin: 'com.android.application'
 
 group   = 'org.jmonkeyengine'
-version = jmeVersion + '-' + jmeVersionTag
+version = jmeFullVersion
 
 sourceCompatibility = '1.6'
 

+ 4 - 4
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 = "<b>jMonkeyEngine ${jmeMainVersion} ${project.name}</b>"
+    options.docTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
+    options.windowTitle = "jMonkeyEngine ${jmeFullVersion} ${project.name} Javadoc"
+    options.header = "<b>jMonkeyEngine ${jmeFullVersion} ${project.name}</b>"
     options.author = "true"
     options.use = "true"
     options.charSet = "UTF-8"

+ 9 - 8
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

+ 32 - 13
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 + ". " + \