<?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>7.2.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>7.2.0</elasticsearch.version>

        <!-- We use the build timestamp in the RPM version, so change the format to ensure that there
             are no invalid characters such as colons (:) -->
        <maven.build.timestamp.format>yyyy_MM_dd_HH_mm</maven.build.timestamp.format>
        <!-- Set to 0.${maven.build.timestamp}.SNAPSHOT when using a SNAPSHOT version to uniquely identify the RPMs -->
	<rpmRelease>1</rpmRelease>
        <packageSummary>Time series aggregation for flow records in Elasticsearch</packageSummary>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.plugin</groupId>
            <artifactId>aggs-matrix-stats-client</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.test</groupId>
            <artifactId>framework</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>net.sf.debian-maven</groupId>
                    <artifactId>debian-maven-plugin</artifactId>
                    <version>1.0.6</version>
                    <executions>
                        <execution>
                            <id>generate-deb</id>
                            <goals>
                                <goal>package</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <targetDir>${project.build.directory}/releases</targetDir>
                        <packageVersion>${project.version}</packageVersion>
                        <packageRevision>1</packageRevision>
                        <packageSection>contrib/net</packageSection>
                        <packageTitle>${packageSummary}</packageTitle>
                        <packageDescription>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.
                        </packageDescription>
                        <packageDependencies>
                            <packageDependency>elasticsearch (= ${elasticsearch.version})</packageDependency>
                        </packageDependencies>
                        <maintainerName>Benjamin Reed</maintainerName>
                        <maintainerEmail>ranger@opennms.org</maintainerEmail>
                        <excludeAllArtifacts>true</excludeAllArtifacts>
                        <excludeAllDependencies>true</excludeAllDependencies>
                        <includeAttachedArtifacts>false</includeAttachedArtifacts>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>rpm-maven-plugin</artifactId>
                    <version>2.2.0</version>
                    <executions>
                        <execution>
                            <id>generate-rpm</id>
                            <goals>
                                <goal>rpm</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <summary>${packageSummary}</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/releases/${project.name}-${project.version}/</location>
                                    </source>
                                </sources>
                            </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.8.1</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.1.0</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.1</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-resources-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>copy-filtered-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>copy-deb-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${basedir}/target/deb/usr/share/elasticsearch/plugins/drift/
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>target/releases/${project.name}-${project.version}/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-deb-docs</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <overwrite>true</overwrite>
                            <outputDirectory>${basedir}/target/deb/usr/share/doc/${project.name}/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}</directory>
                                    <includes>
                                        <include>LICENSE.txt</include>
                                        <include>README.md</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.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.local</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>
        <profile>
            <id>build.debs</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <exists>/usr/bin/dpkg-buildpackage</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.sf.debian-maven</groupId>
                        <artifactId>debian-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>gpg</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

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

</project>
