From 61498acc397fa0c5cec93e8ee6da1dbbb83a1c9b Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Sun, 11 Sep 2011 19:14:54 +0000 Subject: [PATCH] extract version number from pom.xml - makes -v optional, check if release script is executed from the 'etc' folder git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@7242 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/etc/extract_release_number.xslt | 7 +++++++ pmd/etc/generate_release.sh | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 pmd/etc/extract_release_number.xslt diff --git a/pmd/etc/extract_release_number.xslt b/pmd/etc/extract_release_number.xslt new file mode 100644 index 0000000000..3cc748f27d --- /dev/null +++ b/pmd/etc/extract_release_number.xslt @@ -0,0 +1,7 @@ + + + + + VERSION: + + diff --git a/pmd/etc/generate_release.sh b/pmd/etc/generate_release.sh index 77278fafbd..b9c5f83003 100644 --- a/pmd/etc/generate_release.sh +++ b/pmd/etc/generate_release.sh @@ -1,11 +1,13 @@ #!/bin/bash usage() { - echo "$(basename ${0}) -v version-number [-d] [-s]" + echo "$(basename ${0}) [-v version-number] [-d] [-s]" echo "" - echo "-v must provide the release's version number" + echo "-v override the release's version number provided in pom.xml" echo "-d no docs generation" echo "-s no SVN tags" + echo "" + echo "This script MUST BE executed from the 'etc' folder of the PMD projet." } check_dependency() { @@ -19,7 +21,7 @@ check_dependency() { fi } -while getopts V:Dh OPT; do +while getopts v:dsh OPT; do case "$OPT" in h) usage @@ -42,14 +44,20 @@ while getopts V:Dh OPT; do done if [ -z ${version} ]; then - usage - exit 1 + check_dependency "xsltproc" + readonly version=$(xsltproc extract_release_number.xslt ../pom.xml | grep VERSION | cut -f2 -d: | sed -e 's/-SNAPSHOT//') fi check_dependency "ant" check_dependency "maven" check_dependency "mvn" +current_dir=$(pwd | sed -e 's/^.*\///') +if [ "${current_dir}" -ne "etc" ], then + echo "release script MUST be executed from the 'etc' folder" + exit 3 +fi + echo "building release version ${version}" pmd_top_dir="$(mktemp -d)"