Use Maven 3 for build

Also, pull and build monasca-common directly instead of using
jars from tarballs.openstack.org since zuul often gets backed
up and jars don't get updated fast enough

Change-Id: I27c964eb2b732c70c0e8c8d2b74b160c921e899d
This commit is contained in:
Craig Bryant 2015-03-27 12:04:07 -06:00
parent f9b918ea48
commit 23d8e0d9b7
6 changed files with 108 additions and 116 deletions

29
common/build_common.sh Executable file
View File

@ -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

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>monasca-persister</groupId>
<artifactId>monasca-persister-download</artifactId>
<artifactId>monasca-persister-common</artifactId>
<version>1.0.0-SNAPSHOT</version>
<url>http://github.com/stackforge/monasca-persister</url>
<packaging>pom</packaging>
@ -11,7 +11,6 @@
<properties>
<!-- Versioning -->
<exec.args>${project.version}</exec.args>
<skipITs>true</skipITs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@ -30,9 +29,16 @@
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>package-execution</id>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>./download.sh</executable>
<executable>./build_common.sh</executable>
</configuration>
</plugin>
</plugins>

View File

@ -1,68 +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-influxdb
"
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

View File

@ -10,7 +10,16 @@
<url>http://github.com/stackforge/monasca-persister</url>
<packaging>jar</packaging>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<gitRevision></gitRevision>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
<computedVersion>${project.version}-${timestamp}-${gitRevision}</computedVersion>
<computedName>${project.artifactId}-${computedVersion}</computedName>
<mon.common.version>1.0.0-SNAPSHOT</mon.common.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

57
pom.xml
View File

@ -4,21 +4,13 @@
<groupId>monasca</groupId>
<artifactId>monasca-persister-base</artifactId>
<version>${computedVersion}</version>
<url>http://github.com/stackforge/monasca-common</url>
<version>1.0.0-SNAPSHOT</version>
<url>http://github.com/stackforge/monasca-persister</url>
<packaging>pom</packaging>
<!--
<prerequisites>
<maven>3.0</maven>
</prerequisites>
-->
<properties>
<!-- Versioning -->
<versionNumber>1.0.0</versionNumber>
<computedVersion>${versionNumber}-SNAPSHOT</computedVersion>
<exec.args>${version} ${sun.java.command}</exec.args>
<skipITs>true</skipITs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -29,55 +21,30 @@
<developerConnection>scm:git:git@github.com:stackforge/monasca-persister</developerConnection>
</scm>
<modules>
<module>download</module>
<module>java</module>
</modules>
<profiles>
<profile>
<id>release-deploy-url-override</id>
<activation>
<property>
<name>BUILD_NUM</name>
</property>
</activation>
<properties>
<computedVersion>${project.version}</computedVersion>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9</version>
<configuration>
<tag>${project.version}</tag>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>some-execution</id>
<id>package-execution</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>clean-execution</id>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>ln</executable>
<arguments>
<argument>-sf</argument>
<argument>java/target</argument>
<argument>target</argument>
</arguments>
<executable>run_maven.sh</executable>
</configuration>
</plugin>
</plugins>

49
run_maven.sh Executable file
View File

@ -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 java; ${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 java/target target
fi
rm -fr apache-maven-3.2.1*
exit $RC