Bjorn Bringert | 1d580d0 | 2012-05-07 16:50:46 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # This script checks the java version and bails if it's less |
| 4 | # than Java6 (because we use @Override annotations on interface |
| 5 | # overriding methods. It then proceeds to do a maven build that |
| 6 | # first cleans, then builds the normal lifecycle through compilation |
| 7 | # unit testing (if available) up to packaging. It then packages |
| 8 | # the source, javadocs, and maven site. It then signs the |
| 9 | # artifacts with whatever pgp signature is the default of the |
| 10 | # user executing it, and then deploys to the repository contained |
| 11 | # in the distributionManagement section of the pom. |
| 12 | # |
| 13 | # author: cgruber@google.com (Christian Edward Gruber) |
| 14 | # |
| 15 | if [[ -n ${JAVA_HOME} ]] ; then |
| 16 | JAVA_CMD=${JAVA_HOME}/bin/java |
| 17 | else |
| 18 | JAVA_CMD=java |
| 19 | fi |
| 20 | java_version="$(${JAVA_CMD} -version 2>&1 | grep -e 'java version' | awk '{ print $3 }')" |
| 21 | |
| 22 | # This test sucks, but it's short term |
| 23 | # TODO(cgruber) strip the quotes and patch version and do version comparison. |
| 24 | greater_than_java5="$(echo ${java_version} | grep -e '^"1.[67]')" |
| 25 | |
| 26 | if [[ -z ${greater_than_java5} ]] ; then |
| 27 | echo "Your java version is ${java_version}." |
| 28 | echo "You must use at least a java 6 JVM to build and deploy this software." |
| 29 | exit 1 |
| 30 | else |
| 31 | echo "Building with java ${java_version}" |
| 32 | fi |
| 33 | |
| 34 | if [[ $# > 0 ]]; then |
| 35 | params+=" -Dgpg.keyname=${1}" |
| 36 | gpg_sign_plugin=" gpg:sign" |
| 37 | fi |
| 38 | cmd="mvn clean package source:jar site:jar javadoc:jar ${gpg_sign_plugin} deploy ${params}" |
| 39 | echo "Executing ${cmd}" |
| 40 | ${cmd} |