diff --git a/common/build_common.sh b/common/build_common.sh new file mode 100755 index 0000000..70801fe --- /dev/null +++ b/common/build_common.sh @@ -0,0 +1,29 @@ +#!/bin/sh +set -x +ME=`whoami` +echo "Running as user: $ME" +MVN=$1 +VERSION=$2 + +check_user() { + ME=$1 + if [ "${ME}" != "jenkins" ]; then + echo "\nERROR: Download monasca-common and do a mvn install to install the monasca-commom jars\n" 1>&2 + exit 1 + fi +} + +BUILD_COMMON=false +POM_FILE=~/.m2/repository/monasca-common/monasca-common/${VERSION}/monasca-common-${VERSION}.pom +if [ ! -r "${POM_FILE}" ]; then + check_user ${ME} + BUILD_COMMON=true +fi + +# This should only be done on the stack forge system +if [ "${BUILD_COMMON}" = "true" ]; then + git clone https://github.com/stackforge/monasca-common + cd monasca-common + ${MVN} clean + ${MVN} install +fi diff --git a/download/pom.xml b/common/pom.xml similarity index 74% rename from download/pom.xml rename to common/pom.xml index a578688..74da6c6 100644 --- a/download/pom.xml +++ b/common/pom.xml @@ -2,16 +2,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - monasca-thresh - monasca-thresh-download + monasca-api + monasca-api-common 1.0.0-SNAPSHOT - http://github.com/stackforge/monasca-thresh + http://github.com/stackforge/monasca-api pom ${project.version} - true UTF-8 UTF-8 @@ -30,9 +29,16 @@ exec + + package-execution + clean + + exec + + - ./download.sh + ./build_common.sh diff --git a/download/download.sh b/download/download.sh deleted file mode 100755 index a1b4483..0000000 --- a/download/download.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -set -x -ME=`whoami` -echo "Running as user: $ME" -VERSION=$1 - -check_user() { - ME=$1 - if [ "${ME}" != "jenkins" ]; then - echo "\nERROR: Download monasca-common and do a mvn install to install the monasca-commom jars\n" 1>&2 - exit 1 - fi -} - -# TODO: Grep these out of the pom itself rather than have them explicitly listed -JARS=" -monasca-common-util -monasca-common-model -monasca-common-persistence -monasca-common-streaming -monasca-common-kafka -monasca-common-testing -" -for JAR in $JARS; do - JARFILE=~/.m2//repository/monasca-common/${JAR}/${VERSION}/${JAR}-${VERSION}.jar - if [ ! -r "$JARFILE" ]; then - check_user ${ME} - # Download it from stackforge - FILE=`basename $JARFILE` - curl http://tarballs.openstack.org/ci/monasca-common/${FILE} > ${FILE} - # Upload into the local repository - POM=META-INF/maven/monasca-common/${JAR}/pom.xml - jar -xvf ${FILE} ${POM} - TMPFILE=pom.$$ - sed -e "s/\${computedVersion}/${VERSION}/" ${POM} > ${TMPFILE} - mv ${TMPFILE} ${POM} - mvn install:install-file -Dfile=${FILE} -DgroupId=monasca-common \ - -DartifactId=${JAR} -Dversion=${VERSION} -Dpackaging=jar -DpomFile=${POM} - fi -done - -POM_FILE=~/.m2/repository/monasca-common/monasca-common/${VERSION}/monasca-common-${VERSION}.pom -if [ ! -r "${POM_FILE}" ]; then - check_user ${ME} - TMPDIR=pom_tmp.$$ - mkdir -p ${TMPDIR} - curl https://raw.githubusercontent.com/stackforge/monasca-common/master/java/pom.xml > ${TMPDIR}/pom.xml - mvn install:install-file -DgroupId=monasca-common -DartifactId=monasca-common -Dversion=${VERSION} -Dpackaging=pom -Dfile=${TMPDIR}/pom.xml - rm -fr ${TMPDIR} -fi - -TEST_JARS=" -monasca-common-streaming -" -for TEST_JAR in $TEST_JARS; do - JARFILE=~/.m2//repository/monasca-common/${TEST_JAR}/${VERSION}/${TEST_JAR}-${VERSION}-tests.jar - if [ ! -r "$JARFILE" ]; then - check_user ${ME} - # Download it from stackforge - FILE=`basename $JARFILE` - curl http://tarballs.openstack.org/ci/monasca-common/${FILE} > ${FILE} - # Upload into the local repository - POM=META-INF/maven/monasca-common/${TEST_JAR}/pom.xml - jar -xvf ${FILE} ${POM} - TMPFILE=pom.$$ - sed -e "s/\${computedVersion}/${VERSION}/" ${POM} > ${TMPFILE} - mv ${TMPFILE} ${POM} - mvn install:install-file -Dfile=${FILE} -DgroupId=monasca-common \ - -DartifactId=${TEST_JAR} -Dversion=${VERSION} -Dpackaging=test-jar -DpomFile=${POM} - fi -done diff --git a/pom.xml b/pom.xml index f02d966..e4f2ac1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,21 +4,13 @@ monasca monasca-thresh-base - ${computedVersion} - http://github.com/stackforge/monasca-common + 1.0.0-SNAPSHOT + http://github.com/stackforge/monasca-thresh pom - - - 1.0.0 - ${versionNumber}-SNAPSHOT - + ${version} ${sun.java.command} true UTF-8 UTF-8 @@ -29,55 +21,30 @@ scm:git:git@github.com:stackforge/monasca-thresh - - download - thresh - - - - - release-deploy-url-override - - - BUILD_NUM - - - - ${project.version} - - - - - - org.apache.maven.plugins - maven-scm-plugin - 1.9 - - ${project.version} - - org.codehaus.mojo exec-maven-plugin 1.1.1 - some-execution + package-execution package exec + + clean-execution + clean + + exec + + - ln - - -sf - thresh/target - target - + run_maven.sh diff --git a/run_maven.sh b/run_maven.sh new file mode 100755 index 0000000..aa845a7 --- /dev/null +++ b/run_maven.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Download maven 3 if the system maven isn't maven 3 +VERSION=`mvn -v | grep "Apache Maven 3"` +if [ -z "${VERSION}" ]; then + curl http://archive.apache.org/dist/maven/binaries/apache-maven-3.2.1-bin.tar.gz > apache-maven-3.2.1-bin.tar.gz + tar -xvzf apache-maven-3.2.1-bin.tar.gz + MVN=${PWD}/apache-maven-3.2.1/bin/mvn +else + MVN=mvn +fi + +# Get the expected common version +COMMON_VERSION=$1 +# Get rid of the version argument +shift + +# Get rid of the java property name containing the args +shift + +RUN_BUILD=false +for ARG in $*; do + if [ "$ARG" = "package" ]; then + RUN_BUILD=true + fi + if [ "$ARG" = "install" ]; then + RUN_BUILD=true + fi +done + +if [ $RUN_BUILD = "true" ]; then + ( cd common; ./build_common.sh ${MVN} ${COMMON_VERSION} ) + RC=$? + if [ $RC != 0 ]; then + exit $RC + fi +fi + +# Invoke the maven 3 on the real pom.xml +( cd thresh; ${MVN} -DgitRevision=`git rev-list HEAD --max-count 1 --abbrev=0 --abbrev-commit` $* ) + +RC=$? + +# Copy the jars where the publisher will find them +if [ $RUN_BUILD = "true" ]; then + ln -sf thresh/target target +fi + +rm -fr apache-maven-3.2.1* +exit $RC diff --git a/thresh/pom.xml b/thresh/pom.xml index 08205ca..3f11250 100644 --- a/thresh/pom.xml +++ b/thresh/pom.xml @@ -16,6 +16,11 @@ --> + + ${maven.build.timestamp} + yyyy-MM-dd'T'HH:mm:ss + ${project.version}-${timestamp}-${gitRevision} + ${project.artifactId}-${computedVersion} 1.0.0-SNAPSHOT 0.9.1-incubating false