Get the java build working in StackForge

Move the java code to the new java directory

The poms are now maven 2 compatible
Change-Id: Idcc33bc27d202d64ffe4cbd528de6142db7dd841
This commit is contained in:
Craig Bryant 2015-02-09 13:30:37 -07:00
parent 1660589c3e
commit 94b729d283
145 changed files with 617 additions and 400 deletions

View File

@ -4,14 +4,27 @@
The full API Specification can be found in [docs/monasca-api-spec.md](docs/monasca-api-spec.md)
## Build
## Java Build
Requires monasca-common from https://github.com/stackforge/monasca-common. Download and do mvn install.
Requires monasca-common from https://github.com/stackforge/monasca-common. Download and do mvn install. Then:
```
mvn clean install
cd java
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.
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.
Currently this build is executed on the bare-precise nodes in StackForge and they only have maven 2. So, this build must be kept compatible with Maven 2. If another monasca-common jar is added as a dependency to java/pom.xml, it must also be added to download/download.sh.
Combining monasca-common, monasca-thresh, monasaca-api and monasca-persister into one build would vastly simplify the builds but that is a future task.`
## Usage
```

72
download/download.sh Executable file
View File

@ -0,0 +1,72 @@
#!/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

40
download/pom.xml Normal file
View File

@ -0,0 +1,40 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>monasca-persister</groupId>
<artifactId>monasca-persister-download</artifactId>
<version>1.0.0-SNAPSHOT</version>
<url>http://github.com/stackforge/monasca-persister</url>
<packaging>pom</packaging>
<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>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>package-execution</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>./download.sh</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>

412
java/pom.xml Normal file
View File

@ -0,0 +1,412 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>monasca-api</groupId>
<artifactId>monasca-api</artifactId>
<version>1.0.0</version>
<url>http://github.com/stackforge/monasca-api</url>
<packaging>jar</packaging>
<properties>
<computedVersion>${project.version}-${timestamp}-${buildNumber}</computedVersion>
<computedName>${project.artifactId}-${computedVersion}</computedName>
<mon.common.version>1.0.0-SNAPSHOT</mon.common.version>
<dropwizard.version>0.7.0</dropwizard.version>
<skipITs>false</skipITs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<shadedJarName>${project.artifactId}-${project.version}-shaded
</shadedJarName>
</properties>
<scm>
<connection>scm:git:git@github.com:stackforge/monasca-api</connection>
<developerConnection>scm:git:git@github.com:stackforge/monasca-api</developerConnection>
</scm>
<profiles>
<profile>
<id>release-deploy-url-override</id>
<activation>
<property>
<name>BUILD_NUM</name>
</property>
</activation>
<properties>
<computedVersion>${versionNumber}.${BUILD_NUM}</computedVersion>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-influxdb</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-model</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-persistence</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-util</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-kafka</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-middleware</artifactId>
<version>${mon.common.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-db</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jdbi</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-assets</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jersey</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>2.2.0-incubating</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.0</version>
<exclusions>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>1.0</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-testing</artifactId>
<version>${mon.common.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>monasca-common</groupId>
<artifactId>monasca-common-dropwizard</artifactId>
<version>${mon.common.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<version>${dropwizard.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java</artifactId>
<version>0.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/debs</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<shortRevisionLength>6</shortRevisionLength>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
<configuration>
<excludedGroups>performance,functional,integration,database,slow
</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<groups>performance,functional,integration,database,slow</groups>
<skipTests>${skipITs}</skipTests>
<parallel>methods</parallel>
<threadCount>4</threadCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2</version>
<configuration>
<finalName>${computedName}</finalName>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<!-- *:* can't be used for artifact because we are using an older shade plugin -->
<artifact>org.eclipse.jetty.orbit:javax.servlet</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<artifactSet>
<excludes>
<exclude>org.hamcrest:hamcrest-core</exclude>
<exclude>org.hamcrest:hamcrest-library</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>monasca.api.MonApiApplication</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptors>
<descriptor>src/assembly/tar.xml</descriptor>
</descriptors>
<finalName>${artifactNamedVersion}</finalName>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<deb>${project.basedir}/debs/binaries/${computedName}.deb</deb>
<dataSet>
<data>
<type>file</type>
<src>${project.build.directory}/${shadedJarName}.jar</src>
<dst>/opt/monasca/monasca-api.jar</dst>
</data>
<data>
<type>file</type>
<src>${project.basedir}/src/deb/init/monasca-api.conf</src>
<dst>/etc/init/monasca-api.conf</dst>
</data>
<data>
<type>file</type>
<src>${project.basedir}/src/deb/etc/api-config.yml-sample
</src>
<dst>/etc/monasca/api-config.yml-sample</dst>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.2</version>
<configuration>
<tag>${project.version}</tag>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -17,7 +17,7 @@
</fileSets>
<files>
<file>
<source>${project.build.directory}/${computedName}.jar</source>
<source>${project.build.directory}/${shadedJarName}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>monasca-api.jar</destName>
</file>

Some files were not shown because too many files have changed in this diff Show More