Improved build script.

This commit is contained in:
Christian P. MOMON 2018-01-07 02:54:49 +01:00
parent 2e15c98bd4
commit 3d10add925
6 changed files with 191 additions and 34 deletions

View File

@ -71,7 +71,7 @@
<!-- AUTOMATIC MANAGEMENT -->
<buildnumber file="build.num" description="Id of the build"/>
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}" />
<property name="dist.version" value="${product.revision.major}.${product.revision.minor}.${build.number}${dist.snapshot}" />
<property name="dist.name" value="${product.name}-${dist.version}" />
<property name="dist.dir" value="${basedir}/dist/${product.name}-${dist.version}" />
<tstamp>

View File

@ -2,4 +2,5 @@
<project default="dist" name="Build">
<!-- -->
<import file="build-appjar.xml" />
<property name="dist.snapshot" value="" />
</project>

27
build-snapshot.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<project default="snapshot" name="Build Snapshot">
<!-- -->
<import file="build-appjar.xml" />
<property name="buildnum.file" value="${basedir}/build.num" />
<property name="buildnum.tmpfile" value="${basedir}/build.num.tmp" />
<tstamp>
<format property="dist.snapshot.number" pattern="yyyyMMddHHmmss" />
</tstamp>
<property name="dist.snapshot" value="-SNAPSHOT-${dist.snapshot.number}" />
<!-- ***** Store ***** -->
<target name="store" description="Store the build number version">
<copy file="${buildnum.file}" tofile="${buildnum.tmpfile}" overwrite="true" />
</target>
<!-- ***** Restore ***** -->
<target name="restore" description="Restore the build number version">
<copy file="${buildnum.tmpfile}" tofile="${buildnum.file}" overwrite="true" />
<delete file="${buildnum.tmpfile}" />
</target>
<!-- ***** Snapshot ***** -->
<target name="snapshot" description="Build a snapshot" depends="store,dist,restore">
</target>
</project>

View File

@ -2,4 +2,5 @@
<project default="buildandgit" name="BuildAndGit">
<!-- -->
<import file="build-appjar.xml" />
<property name="dist.snapshot" value="" />
</project>

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sat Jan 06 02:22:43 CET 2018
#Sun Jan 07 02:45:10 CET 2018
build.number=0

192
build.sh
View File

@ -1,40 +1,168 @@
#/bin/bash
echo "Hebdobot build"
#
# Display help.
#
function help
{
echo "Hebdobot build script."
echo "Usage: build.sh [ -h | -help | --help | -snapshot | -local | -full ]"
echo " -h, -help, --help display this help."
echo " -snapshot, --snapshot build a snapshot."
echo " -local, --local build a new version without tag nor version number commit nor GIT push."
echo " -tagandpush, --tagandpush build a new version with tag, version number commit and GIT push."
echo ""
}
okCount=0
#
# Build snapshot.
#
function build_snapshot
{
okCount=0
# Ant check.
antCheck=`which ant`
if [[ "$antCheck" =~ ^/.* ]]; then
echo "Ant requirement................ OK"
let "okCount+=1"
else
echo "Ant requirement................ MISSING"
fi
# Javac check.
javacCheck=`which javac`
if [[ "$javacCheck" =~ ^/.* ]]; then
echo "Javac requirement.............. OK"
let "okCount+=1"
else
echo "Javac requirement.............. MISSING"
fi
# Java version check.
javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
if [ "$okCount" == 3 ]; then
echo "Requirement OK"
ant -f build-snapshot.xml
else
echo "Requirement MISSING, build abort"
fi
}
# Ant check.
antCheck=`which ant`
if [[ "$antCheck" =~ ^/.* ]]; then
echo "Ant requirement................ OK"
let "okCount+=1"
#
# Build local.
#
function build_local
{
okCount=0
# Ant check.
antCheck=`which ant`
if [[ "$antCheck" =~ ^/.* ]]; then
echo "Ant requirement................ OK"
let "okCount+=1"
else
echo "Ant requirement................ MISSING"
fi
# Javac check.
javacCheck=`which javac`
if [[ "$javacCheck" =~ ^/.* ]]; then
echo "Javac requirement.............. OK"
let "okCount+=1"
else
echo "Javac requirement.............. MISSING"
fi
# Java version check.
javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
if [ "$okCount" == 3 ]; then
echo "Requirement OK"
ant -f build-local.xml
else
echo "Requirement MISSING, build abort"
fi
}
#
# Build tagandpush.
#
function build_tagandpush
{
okCount=0
# Ant check.
antCheck=`which ant`
if [[ "$antCheck" =~ ^/.* ]]; then
echo "Ant requirement................ OK"
let "okCount+=1"
else
echo "Ant requirement................ MISSING"
fi
# Javac check.
javacCheck=`which javac`
if [[ "$javacCheck" =~ ^/.* ]]; then
echo "Javac requirement.............. OK"
let "okCount+=1"
else
echo "Javac requirement.............. MISSING"
fi
# Java version check.
javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
# Git check.
gitCheck=`which git 2>&1`
if [[ "$gitCheck" =~ ^.*\ 1.8 ]]; then
echo "GIT requirement................ OK"
let "okCount+=1"
else
echo "GIT requirement................ MISSING"
fi
if [ "$okCount" == 4 ]; then
echo "Requirement OK"
ant -f build-tagandpush.xml
else
echo "Requirement MISSING, build abort"
fi
}
#
# Main.
#
if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
help
elif [ "$1" == "-snapshot" ] || [ "$1" == "--snapshot" ] ; then
build_snapshot
elif [ "$1" == "-local" ] || [ "$1" == "--local" ] ; then
build_local
elif [ "$1" == "-tagandpush" ] || [ "$1" == "--tagandpush" ] ; then
build_tagandpush
else
echo "Ant requirement................ MISSING"
echo "Invalid parameters."
help
fi
# Javac check.
javacCheck=`which javac`
if [[ "$javacCheck" =~ ^/.* ]]; then
echo "Javac requirement.............. OK"
let "okCount+=1"
else
echo "Javac requirement.............. MISSING"
fi
# Java version check.
javaVersionCheck=`javac -version 2>&1`
if [[ "$javaVersionCheck" =~ ^.*\ 1.8 ]]; then
echo "Java 8 version requirement..... OK"
let "okCount+=1"
else
echo "Java 8 version requirement..... MISSING"
fi
if [ "$okCount" == 3 ]; then
echo "Requirement OK"
ant -f build.xml
else
echo "Requirement MISSING, build abort"
fi