get default maven version from distribution file name Also this patch fixes an error when in the dist folder are multiple files Change-Id: I56438e09c0817f010bf86f9aa49e3d0c7f8039ec (cherry picked from commit 6bc4372cc73a1155fd8dcd919571aed2f54daef5)
diff --git a/maven/push-gwt.sh b/maven/push-gwt.sh index ff62b38..c2064b9 100755 --- a/maven/push-gwt.sh +++ b/maven/push-gwt.sh
@@ -24,44 +24,35 @@ # repo id is ignored by local repo repoId=${GWT_MAVEN_REPO_ID:=none} -# prompt for info -read -e -p"GWT version for Maven (ex: 2.4.0): " gwtVersion -case $gwtVersion in - *.*.* ) - ;; - *.*.*-* ) - ;; - * ) - echo "Please enter a version of the form x.y.z or x.y.z-abc" - exit 1;; -esac - +# use GWT_DIST_FILE to specify the default distribution file gwtTrunk=$(dirname $(pwd)) -if [ -f ${gwtTrunk}/build/dist/gwt-*.zip ]; then - gwtPathDefault=$(ls ${gwtTrunk}/build/dist/gwt-*.zip | head -n1) - gwtPathPrompt=" ($gwtPathDefault)" +gwtPathDefault=${GWT_DIST_FILE:=$(ls -t1 ${gwtTrunk}/build/dist/gwt-*.zip 2>/dev/null | head -1)} +if [[ -f "$gwtPathDefault" ]]; then + gwtPathPrompt="($gwtPathDefault)" fi + +VERSION_REGEX='[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*-*.*' + +# use GWT_VERSION to specify the default version or get it from the file name +gwtVersionDefault=${GWT_VERSION:=$(expr "$gwtPathDefault" : '.*gwt-\('$VERSION_REGEX'\)\.zip')} + +# prompt for info +read -e -p"GWT version for Maven (${gwtVersionDefault:-ex: 2.8.0-SNAPSHOT}): " gwtVersion +gwtVersion=${gwtVersion:=$gwtVersionDefault} +if ! expr "$gwtVersion" : "$VERSION_REGEX" >/dev/null; then + echo "Please enter a version of the form x.y.z or x.y.z-abc" + exit 1 +fi + read -e -p"Path to GWT distro zip $gwtPathPrompt: " gwtPath -case $gwtPath in - "" ) - gwtPath=$gwtPathDefault - ;; - * ) - ;; -esac -if [[ "$gwtPath" == "" || ! -f $gwtPath ]]; then +gwtPath=${gwtPath:=$gwtPathDefault} +if [[ ! -f $gwtPath ]]; then echo "ERROR: Cannot find file at \"$gwtPath\"" exit 1 fi read -e -p"Deploy to repo URL ($repoUrlDefault): " repoUrl -case $repoUrl in - "" ) - repoUrl=$repoUrlDefault - ;; - * ) - ;; -esac +repoUrl=${repoUrl:=$repoUrlDefault} # setting the repoUrl to 'install' will instruct to maven-gwt to # execute the install goal instead of the deploy one. @@ -69,7 +60,9 @@ repoUrl=install fi +# use GWT_GPG_PASS environment var by default if set read -p"GPG passphrase for jar signing (may skip for local deployment): " gpgPassphrase +gpgPassphrase=${gpgPassphrase:=$GWT_GPG_PASS} maven-gwt "$gwtVersion" \ "$gwtPath" \