<?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>org.opennms.elasticsearch</groupId>
    <artifactId>elasticsearch-drift-plugin</artifactId>
    <version>1.0.0</version>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>

    <properties>
        <elasticsearch.version>6.2.4</elasticsearch.version>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
        <rpmRelease>0.${maven.build.timestamp}.SNAPSHOT</rpmRelease>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>aggs-matrix-stats-client</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.test</groupId>
            <artifactId>framework</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codelibs.elasticsearch.module</groupId>
            <artifactId>lang-painless</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.10.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.10.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/filtered-resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>rpm-maven-plugin</artifactId>
                    <version>2.1.5</version>
                    <executions>
                        <execution>
                            <id>generate-rpm</id>
                            <goals>
                                <goal>rpm</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <summary>Time series aggregation for flow records in Elasticsearch</summary>
                        <description>This plugin provides a new aggregation function proportional_sum that can be used to
group documents that contain a date range into multiple buckets, and calculate a sum
on a per bucket basis using a ratio that is proportional to the range of time in which
the document spent in that bucket.

This aggregation function behaves like a hybrid of both the Metrics and Bucket type
aggregations since we both create buckets and calculate a new metric.</description>
                        <license>Apache License, Version 2.0</license>
                        <group>Applications/System</group>
                        <prefix>/usr/share/elasticsearch/plugins</prefix>
                        <defaultDirmode>755</defaultDirmode>
                        <defaultFilemode>644</defaultFilemode>
                        <defaultUsername>root</defaultUsername>
                        <defaultGroupname>wheel</defaultGroupname>
                        <release>${rpmRelease}</release>
                        <defineStatements>
                            <!-- <defineStatement>_unpackaged_files_terminate_build 0</defineStatement> -->
                        </defineStatements>
                        <requires>
                            <require>elasticsearch = ${elasticsearch.version}</require>
                        </requires>
                        <mappings>
                            <mapping>
                                <directory>/usr/share/elasticsearch/plugins/drift</directory>
                                <sources>
                                    <source><location>target/classes/plugin-descriptor.properties</location></source>
                                </sources>
                            </mapping>
                            <mapping>
                                <directory>/usr/share/elasticsearch/plugins/drift</directory>
                                <sources>
                                    <source><location>target/${project.name}-${project.version}.jar</location></source>
                                </sources>
                            </mapping>
                            <mapping>
                                <directory>/usr/share/elasticsearch/plugins/drift</directory>
                                <dependency>
                                    <includes>
                                        <include>org.elasticsearch.plugin:aggs-matrix-stats-client</include>
                                    </includes>
                                </dependency>
                            </mapping>
                            <mapping>
                                <directory>/usr/share/doc/elasticsearch-drift-plugin</directory>
                                <documentation>true</documentation>
                                <sources>
                                    <source><location>LICENSE.txt</location></source>
                                    <source><location>README.md</location></source>
                                </sources>
                            </mapping>
                        </mappings>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <outputDirectory>${project.build.directory}/releases/</outputDirectory>
                    <descriptors>
                        <descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20.1</version>
                <configuration>
                    <argLine>-Dtests.security.manager=false</argLine>
                    <excludes>
                        <exclude>**/*IT.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <excludes>
                                <exclude>none</exclude>
                            </excludes>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <groupId>org.sonatype.plugins</groupId>
              <artifactId>nexus-staging-maven-plugin</artifactId>
              <version>1.6.8</version>
              <extensions>true</extensions>
              <configuration>
                <serverId>ossrh</serverId>
                <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                <autoReleaseAfterClose>true</autoReleaseAfterClose>
              </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>build.rpms.usr</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>/usr/bin/rpmbuild</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>build.rpms.usr.clocal</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>/usr/local/bin/rpmbuild</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <distributionManagement>
      <snapshotRepository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      </snapshotRepository>
    </distributionManagement>

</project>
