From 8579f4663a58b4bb1f3560fb5582abf3202094df Mon Sep 17 00:00:00 2001 From: Drew Short Date: Sat, 25 Jan 2014 22:16:42 -0500 Subject: [PATCH] Changes to the build scripts, added a script to increase patch version, tag and then build a release. --- .gitignore | 3 +++ buildAndPackage.sh | 3 --- createPatchRelease.sh | 24 ++++++++++++++++++ createTestRelease.sh | 5 ++++ pom.xml | 3 +++ .../java/com/sothr/imagetools/AppConfig.java | 8 +++++- src/main/resources/default.properties | 2 +- .../com/sothr/imagetools/util/Version.scala | 25 ++++++++++--------- src/test/resources/default.properties | 2 +- 9 files changed, 57 insertions(+), 18 deletions(-) delete mode 100755 buildAndPackage.sh create mode 100755 createPatchRelease.sh create mode 100755 createTestRelease.sh diff --git a/.gitignore b/.gitignore index f7be0a5..bd7b145 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ version.info *.debug* *.info* *.err* + +#POM versions backup +*.versionsBackup diff --git a/buildAndPackage.sh b/buildAndPackage.sh deleted file mode 100755 index 8991f0f..0000000 --- a/buildAndPackage.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -. build.sh -. package.sh diff --git a/createPatchRelease.sh b/createPatchRelease.sh new file mode 100755 index 0000000..5a63860 --- /dev/null +++ b/createPatchRelease.sh @@ -0,0 +1,24 @@ +#!/bin/bash +#Update the release version of the project +#version string will look similar to this: 0.1.0-DEV-27-060aec7 +VERSION=$(head -1 ./version.info) + +#do work on the version to get the correct info +#we need the version string from above to look like this: 0.1.1-DEV +IFS='.' read -a arr <<< "$VERSION" +#results in [0,1,0-DEV-27-060aec7] +IFS='-' read -a arr2 <<< "${arr[2]}" +#results in [0,DEV,27,060aec7] +let patch=${arr2[0]}+1 +#echo $patch +VERSION="${arr[0]}.${arr[1]}.$patch-${arr2[1]}" +#echo $VERSION + +#update the POM +mvn versions:set -DnewVersion=$VERSION + +#tag the build +git tag -a v$VERSION -m "Patch Release Version $VERSION" + +. build.sh +. package.sh diff --git a/createTestRelease.sh b/createTestRelease.sh new file mode 100755 index 0000000..ee64d5f --- /dev/null +++ b/createTestRelease.sh @@ -0,0 +1,5 @@ +#!/bin/bash +#Do not change versions as this is a test build with artifacts +#Build and package the current version +. build.sh +. package.sh \ No newline at end of file diff --git a/pom.xml b/pom.xml index ce5abd5..f3f0639 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,9 @@ + 0 + 1 + DEV UTF-8 1.7 3.8.1 diff --git a/src/main/java/com/sothr/imagetools/AppConfig.java b/src/main/java/com/sothr/imagetools/AppConfig.java index 9d9c276..9b7cb09 100644 --- a/src/main/java/com/sothr/imagetools/AppConfig.java +++ b/src/main/java/com/sothr/imagetools/AppConfig.java @@ -25,7 +25,13 @@ class AppConfig { public static void configureApp() { //configSimpleLogging(); - loadProperties(); + if (!configuredLogging) { + BasicConfigurator.configure(); + loadProperties(); + BasicConfigurator.resetConfiguration(); + } else { + loadProperties(); + } configLogging(); } diff --git a/src/main/resources/default.properties b/src/main/resources/default.properties index 341e43b..148f5b2 100644 --- a/src/main/resources/default.properties +++ b/src/main/resources/default.properties @@ -1,6 +1,6 @@ #Default Properties File #Image Tools version: ${project.version} -version=${project.version} +version=${build-version} #Default App Settings app.timed=false diff --git a/src/main/scala/com/sothr/imagetools/util/Version.scala b/src/main/scala/com/sothr/imagetools/util/Version.scala index 24f0ee1..e81864d 100644 --- a/src/main/scala/com/sothr/imagetools/util/Version.scala +++ b/src/main/scala/com/sothr/imagetools/util/Version.scala @@ -5,21 +5,22 @@ package com.sothr.imagetools.util */ class Version(val versionString:String) { //parse version into parts - val (major,minor,revision,buildType) = { + //typical version string i.e. 0.1.0-DEV-27-060aec7 + val (major,minor,patch,buildTag,buildNumber,buildHash) = { val splitVersion = versionString.split("""\.""") val splitType = splitVersion(splitVersion.length-1).split("""-""") - (splitVersion(0).toInt,splitVersion(1).toInt,splitType(0).toInt,splitType(1)) + (splitVersion(0).toInt,splitVersion(1).toInt,splitType(0).toInt,splitType(1),splitType(2),splitType(3)) } /* - * -3 = this.revision < that.revision + * -3 = this.patch < that.patch * -2 = this.minor < that.minor * -1 = this.major < that.major * 0 = Identical Versions * 1 = this.major > that.major * 2 = this.minor > that.minor - * 3 = this.revision > that.revision - * 4 = this.buildType != that.buildType + * 3 = this.patch > that.patch + * 4 = this.buildTag != that.buildTag */ def compare(that:Version):Integer = { if (this.hashCode == that.hashCode) return 0 @@ -35,13 +36,13 @@ class Version(val versionString:String) { return -2 //major.minor are the same } else { - if (this.revision > that.revision) { + if (this.patch > that.patch) { return 3 - } else if (this.revision < that.revision) { + } else if (this.patch < that.patch) { return -3 - //major.minor.revision are all the same + //major.minor.patch are all the same } else { - if (this.buildType != that.buildType) { + if (this.buildTag != that.buildTag) { return 4 } //should be caught by the first if, but incase not @@ -52,7 +53,7 @@ class Version(val versionString:String) { } override def toString():String = { - return s"$major.$minor.$revision-$buildType" + return s"$major.$minor.$patch-$buildTag build:$buildNumber code:$buildHash" } override def hashCode(): Int = { @@ -60,8 +61,8 @@ class Version(val versionString:String) { val result:Int = 255 var hash:Int = major hash += minor - hash += revision - hash += buildType.hashCode + hash += patch + hash += buildTag.hashCode return prime * result + hash } } diff --git a/src/test/resources/default.properties b/src/test/resources/default.properties index 0752b0b..c1f03b9 100644 --- a/src/test/resources/default.properties +++ b/src/test/resources/default.properties @@ -1,6 +1,6 @@ #Default Properties File #Image Tools version: ${project.version} -version=${project.version} +version=${build-version} #Default App Settings app.timed=true