<?xml version="1.0"?>
<!--
  ~ Copyright 2016 Groupon.com
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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/maven-v4_0_0.xsd">
  <parent>
    <groupId>com.arpnetworking.build</groupId>
    <artifactId>arpnetworking-parent-pom</artifactId>
    <version>1.0.31</version>
    <relativePath />
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.arpnetworking.kairosdb</groupId>
  <artifactId>kairosdb-histograms</artifactId>
  <packaging>jar</packaging>
  <name>KairosDB Histograms</name>
  <description>Histograms for KairosDB.</description>
  <version>1.0.2</version>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
      <comments>A business-friendly OSS license</comments>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>barp</id>
      <name>Brandon Arp</name>
      <email>brandon.arp@inscopemetrics.com</email>
      <organization>Inscope Metrics</organization>
      <organizationUrl>http://www.inscopemetrics.com</organizationUrl>
      <roles>
        <role>developer</role>
      </roles>
    </developer>
    <developer>
      <id>vkoskela</id>
      <name>Ville Koskela</name>
      <email>ville.koskela@inscopemetrics.com</email>
      <organization>Inscope Metrics</organization>
      <organizationUrl>http://www.inscopemetrics.com</organizationUrl>
      <roles>
        <role>developer</role>
      </roles>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git@github.com:ArpNetworking/kairosdb-histograms.git</connection>
    <developerConnection>scm:git:git@github.com:ArpNetworking/kairosdb-histograms.git</developerConnection>
    <url>https://github.com/arpnetworking/kairosdb-histograms</url>
    <tag>kairosdb-histograms-1.0.2</tag>
  </scm>

  <properties>
    <!--Dependency versions-->
    <aspectjrt.version>1.8.9</aspectjrt.version>
    <guice.version>3.0</guice.version>
    <guava.version>19.0</guava.version>
    <kairosdb.version>1.1.3-1</kairosdb.version>
    <slf4j.version>1.7.2</slf4j.version>
    <gson.version>2.2.4</gson.version>
    <org.json.version>chargebee-1.0</org.json.version>
    <junit.version>4.12</junit.version>
    <mockito.version>1.10.19</mockito.version>
    <hamcrest.version>2.0.0.0</hamcrest.version>
    <apache.httpclient.version>4.5.3</apache.httpclient.version>
    <apache.httpcore.version>4.4.6</apache.httpcore.version>
    <findbugs.annotations.version>3.0.1</findbugs.annotations.version>
    <apache.lang3.version>3.4</apache.lang3.version>
    <joda.version>2.3</joda.version>

    <!-- Additional Plugins -->
    <docker.maven.plugin.version>0.16.7</docker.maven.plugin.version>
    <maven.assembly.plugin.version>2.6</maven.assembly.plugin.version>
    <rpm.maven.plugin.version>2.1.5</rpm.maven.plugin.version>

    <!-- Code Coverage -->
    <jacoco.check.line.coverage>0.00</jacoco.check.line.coverage>
    <jacoco.check.branch.coverage>0.00</jacoco.check.branch.coverage>

    <!-- JVM Debug -->
    <debugJavaOptions />
    <debugJavaPort>9000</debugJavaPort>
  </properties>
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
      <!-- Enable Inherited Plugins -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <dockerHostAddress>${docker.host.address}</dockerHostAddress>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.rimerosolutions.maven.plugins</groupId>
        <artifactId>wrapper-maven-plugin</artifactId>
        <inherited>false</inherited>
      </plugin>

      <!-- Project Specific Plugins -->
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>appassembler-maven-plugin</artifactId>
        <configuration>
          <programs>
            <program>
              <id>kairosdb-histogrmas</id>
              <mainClass>com.arpnetworking.DoesNotExist</mainClass>
            </program>
          </programs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>${maven.assembly.plugin.version}</version>
        <executions>
          <execution>
            <id>docker-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <finalName>docker-assembly</finalName>
              <attach>false</attach>
              <tarLongFileMode>posix</tarLongFileMode>
              <descriptors>
                <descripto>src/main/assembly/docker.xml</descripto>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>default-build</id>
            <phase>package</phase>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
          <execution>
            <id>default-remove</id>
            <phase>validate</phase>
            <configuration>
              <removeAll>true</removeAll>
            </configuration>
          </execution>
          <execution>
            <id>default-start</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
            <configuration>
              <skip>${skipIntegrationTests}</skip>
            </configuration>
          </execution>
          <execution>
            <id>default-stop</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
            <configuration>
              <skip>${skipIntegrationTests}</skip>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <showLogs>true</showLogs>
          <images>
            <image>
              <name>arpnetworking/kairos-histograms:${project.version}</name>
              <build>
                <dockerFile>${project.build.directory}/docker-assembly/Dockerfile</dockerFile>
                <tags>
                  <tag>${buildNumber}</tag>
                </tags>
              </build>
              <run>
                <env>
                  <JAVA_OPTS>${debugJavaOptions}</JAVA_OPTS>
                </env>
                <ports>
                  <port>${debugJavaPort}:${debugJavaPort}</port>
                  <port>8080:8080</port>
                </ports>
                <volumes>
                  <bind>
                    <volume>${project.basedir}/logs/docker:/opt/kairosdb/logs</volume>
                  </bind>
                </volumes>
                <wait>
                  <http>
                    <url>http://${docker.host.address}:8080/</url>
                    <method>GET</method>
                    <status>200</status>
                  </http>
                  <!-- NOTE: The service is _really_ slow to start-up under native docker -->
                  <time>150000</time>
                  <kill>1000</kill>
                </wait>
              </run>
            </image>
          </images>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Google -->
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
      <version>${guice.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.json</groupId>
      <artifactId>org.json</artifactId>
      <version>${org.json.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <version>1</version>
      <scope>provided</scope>
    </dependency>
    <!-- KairosDB -->
    <dependency>
      <groupId>org.kairosdb</groupId>
      <artifactId>kairosdb</artifactId>
      <version>${kairosdb.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Test-->
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>findbugs-annotations</artifactId>
      <version>${findbugs.annotations.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>java-hamcrest</artifactId>
      <version>${hamcrest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${apache.httpclient.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${apache.lang3.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${joda.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <version>${apache.httpcore.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>performanceTest</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
              <execution>
                <id>default-test</id>
                <phase>test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <includes>
                    <include>**/*PT.java</include>
                  </includes>
                  <systemPropertyVariables>
                    <logback.configurationFile>${basedir}/src/test/resources/logback-perf.xml</logback.configurationFile>
                  </systemPropertyVariables>
                  <parallel combine.self="override" />
                  <forkCount>1</forkCount>
                  <reuseForks>false</reuseForks>
                  <argLine>-agentlib:hprof=cpu=samples,depth=15,interval=5,force=y,file=${basedir}/target/perf.profile.hprof.txt</argLine>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>rpm</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <version>${rpm.maven.plugin.version}</version>
            <executions>
              <execution>
                <id>generate-rpm</id>
                <goals>
                  <goal>rpm</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <license>Apache 2 License</license>
              <group>System Environment/Daemons</group>
              <autoRequires>false</autoRequires>
              <requires>
                <require>java &gt;= ${jdk.version}</require>
              </requires>
              <mappings>
                <mapping>
                  <directory>/opt/kairosdb/lib</directory>
                  <sources>
                    <source>
                      <location>target/appassembler/lib</location>
                    </source>
                  </sources>
                </mapping>
                <mapping>
                  <directory>/opt/kairosdb/conf</directory>
                  <sources>
                    <source>
                      <location>config</location>
                    </source>
                  </sources>
                </mapping>
              </mappings>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>debug</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <property>
          <name>debug</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <debugJavaOptions>-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${debugJavaPort},suspend=y</debugJavaOptions>
      </properties>
    </profile>
  </profiles>
</project>
