Browse Source

Changes to the build scripts, added a script to increase patch version, tag and then build a release.

master
Drew Short 11 years ago
parent
commit
8579f4663a
  1. 3
      .gitignore
  2. 3
      buildAndPackage.sh
  3. 24
      createPatchRelease.sh
  4. 5
      createTestRelease.sh
  5. 3
      pom.xml
  6. 6
      src/main/java/com/sothr/imagetools/AppConfig.java
  7. 2
      src/main/resources/default.properties
  8. 25
      src/main/scala/com/sothr/imagetools/util/Version.scala
  9. 2
      src/test/resources/default.properties

3
.gitignore

@ -32,3 +32,6 @@ version.info
*.debug*
*.info*
*.err*
#POM versions backup
*.versionsBackup

3
buildAndPackage.sh

@ -1,3 +0,0 @@
#!/bin/bash
. build.sh
. package.sh

24
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

5
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

3
pom.xml

@ -26,6 +26,9 @@
</pluginRepositories>
<properties>
<project.version.major>0</project.version.major>
<project.version.minor>1</project.version.minor>
<project.version.tag>DEV</project.version.tag>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.7</jdk.version>
<lib.junit.version>3.8.1</lib.junit.version>

6
src/main/java/com/sothr/imagetools/AppConfig.java

@ -25,7 +25,13 @@ class AppConfig {
public static void configureApp() {
//configSimpleLogging();
if (!configuredLogging) {
BasicConfigurator.configure();
loadProperties();
BasicConfigurator.resetConfiguration();
} else {
loadProperties();
}
configLogging();
}

2
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

25
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
}
}

2
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

Loading…
Cancel
Save