diff --git a/README.md b/README.md index 712c833d9..b30c524ec 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,7 @@ mvn clean package # StackForge Java Build -There is a pom.xml in the base directory that should only be used for the StackForge build. The StackForge build is a rather strange build because of the limitations of the current StackForge java jobs and infrastructure. This build depends on jars that are built in the monasca-common build. That StrackForge build uploads the completed jars to http://tarballs.openstack.org/ci/monasca-common, but they are just regular jars, and not in a maven repository. Hence, the first thing the maven build from the base project does is execute the build in the download directory. That pom.xml executes the script download.sh which downloads the required jars from http://tarballs.openstack.org/ci/monasca-common and then uses maven to install them in the local directory. The maven install needs the pom.xml so that is pulled from the jar file and then changed to have the right version before the install. - -The monasca-common jars also need the base monasca-common pom.xml. So, that is pulled from gihtub.com and also installed in the local repository. +There is a pom.xml in the base directory that should only be used for the StackForge build. The StackForge build is a rather strange build because of the limitations of the current StackForge java jobs and infrastructure. We have found that the API runs faster if built with maven 3 but the StackForge nodes only have maven 2. This build checks the version of maven and if not maven 3, it downloads a version of maven 3 and uses it. This build depends on jars that are from monasca-common. That StrackForge build uploads the completed jars to http://tarballs.openstack.org/ci/monasca-common, but they are just regular jars, and not in a maven repository and sometimes zuul takes a long time to do the upload. Hence, the first thing the maven build from the base project does is invoke build_common.sh in the common directory. This script clones monasca-common and then invokes maven 3 to build monasca-common in the common directory and install the jars in the local maven repository. Since this is all rather complex, that part of the build only works on StackForge so follow the simple instruction above if you are building your own monasca-api. diff --git a/common/build_common.sh b/common/build_common.sh new file mode 100755 index 000000000..70801fe05 --- /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/download.sh b/download/download.sh deleted file mode 100755 index 0e64979f6..000000000 --- a/download/download.sh +++ /dev/null @@ -1,72 +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-influxdb -monasca-common-model -monasca-common-persistence -monasca-common-util -monasca-common-kafka -monasca-common-middleware -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-dropwizard -" -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/download/pom.xml b/download/pom.xml deleted file mode 100644 index 197250f19..000000000 --- a/download/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - 4.0.0 - - monasca-persister - monasca-persister-download - 1.0.0-SNAPSHOT - http://github.com/stackforge/monasca-persister - pom - - - - ${project.version} - true - UTF-8 - UTF-8 - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.1.1 - - - package-execution - validate - - exec - - - - - ./download.sh - - - - - diff --git a/java/pom.xml b/java/pom.xml index 5c78ff4a1..ca5c02246 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -9,6 +9,10 @@ http://github.com/stackforge/monasca-api jar + + 3.0 + + ${project.version}-${timestamp}-${buildNumber} ${project.artifactId}-${computedVersion} diff --git a/pom.xml b/pom.xml index 61faf0bcd..597931f49 100644 --- a/pom.xml +++ b/pom.xml @@ -4,21 +4,13 @@ monasca monasca-api-base - ${computedVersion} + 1.0.0-SNAPSHOT http://github.com/stackforge/monasca-api 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-api - - download - java - - - - - 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 - java/target - target - + run_maven.sh diff --git a/run_maven.sh b/run_maven.sh new file mode 100755 index 000000000..87f4150d1 --- /dev/null +++ b/run_maven.sh @@ -0,0 +1,48 @@ +#!/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 java; ${MVN} $* ) +RC=$? + +# Copy the jars where the publisher will find them +if [ $RUN_BUILD = "true" ]; then + ln -sf java/target target +fi + +rm -fr apache-maven-3.2.1* +exit $RC