<?xml version="1.0" encoding="UTF-8"?>
<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</groupId>
    <artifactId>monasca-persister</artifactId>
    <version>1.3.0-SNAPSHOT</version>
    <url>http://github.com/openstack/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.3.0-SNAPSHOT</mon.common.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
        <artifactNamedVersion>${project.artifactId}-${project.version}-${timestamp}-${buildNumber}
        </artifactNamedVersion>
        <shadedJarName>${project.artifactId}-${project.version}-shaded
        </shadedJarName>
    </properties>

    <!--Needed for buildnumber-maven-plugin-->
    <scm>
        <connection>scm:git:git@github.com:openstack/monasca-persister</connection>
        <developerConnection>scm:git:git@github.com:openstack/monasca-persister
        </developerConnection>
    </scm>

    <dependencies>
        <dependency>
            <groupId>monasca-common</groupId>
            <artifactId>monasca-common-model</artifactId>
            <version>${mon.common.version}</version>
        </dependency>
        <dependency>
            <groupId>monasca-common</groupId>
            <artifactId>monasca-common-influxdb</artifactId>
            <version>${mon.common.version}</version>
        </dependency>
        <dependency>
            <groupId>monasca-common</groupId>
            <artifactId>monasca-common-cassandra</artifactId>
            <version>${mon.common.version}</version>
        </dependency>
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-mapping</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-extras</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_2.11</artifactId>
            <version>0.8.2.2</version>
            <exclusions>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
            <version>0.7.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.codahale.metrics</groupId>
                    <artifactId>metrics-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-jdbi</artifactId>
            <version>0.7.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>17.0</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>org.influxdb</groupId>
            <artifactId>influxdb-java</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4</version>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.2</version>
                <configuration>
                    <finalName>${artifactNamedVersion}</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>
                </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.persister.PersisterApplication
                                    </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>
                            <packageName>monasca.persister</packageName>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Version>${artifactNamedVersion}</Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <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.2</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <shortRevisionLength>6</shortRevisionLength>
                </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.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jdeb</goal>
                        </goals>
                        <configuration>
                            <deb>${project.basedir}/debs/binaries/${artifactNamedVersion}.deb</deb>
                            <dataSet>
                                <data>
                                    <type>file</type>
                                    <src>${project.build.directory}/${shadedJarName}.jar
                                    </src>
                                    <dst>/opt/monasca/monasca-persister.jar</dst>
                                </data>
                                <data>
                                    <type>file</type>
                                    <src>
                                        ${project.basedir}/src/deb/etc/persister-config.yml-sample
                                    </src>
                                    <dst>/etc/monasca/persister-config.yml-sample</dst>
                                </data>
                            </dataSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


</project>
