<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>com.instaclustr</groupId>
    <artifactId>esop-parent</artifactId>
    <version>4.1.4</version>
    <packaging>pom</packaging>

    <name>esop-parent</name>
    <description>Parent of backup and restoration tooling for Cassandra</description>
    <url>https://github.com/instaclustr/instaclustr-esop</url>

    <modules>
        <module>core</module>
        <module>gcp</module>
        <module>azure</module>
        <module>s3</module>
    </modules>

    <properties>
        <!-- test -->
        <version.embedded.cassandra>4.1.1</version.embedded.cassandra>
        <cassandra.driver.version>4.19.0</cassandra.driver.version>
        <junit.jupiter.version>5.13.4</junit.jupiter.version>
        <mockito.version>2.23.4</mockito.version>

        <maven.jar.plugin.version>3.1.1</maven.jar.plugin.version>
        <maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
        <maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
        <maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
        <maven.source.plugin.version>3.1.0</maven.source.plugin.version>
        <maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
        <maven.javadoc.skip>false</maven.javadoc.skip>

        <dependency.check.plugin.version>12.1.6</dependency.check.plugin.version>
        <nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version>

        <maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>

        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- set this externally upon build if necessary -->
        <nvd.data.dir/>

        <!-- rpm and deb profiles -->
        <maintainer>Various &lt;support@instaclustr.com&gt;</maintainer>
        <version.jdeb>1.8</version.jdeb>
        <version.rpm>1.5.0</version.rpm>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <skip.packages>true</skip.packages>
    </properties>

    <inceptionYear>2019</inceptionYear>

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

    <developers>
        <developer>
            <name>Stefan Miklosovic</name>
            <organization>Instaclustr</organization>
            <email>stefan.miklosovic@instaclustr.com</email>
            <organizationUrl>https://www.instaclustr.com</organizationUrl>
        </developer>
    </developers>

    <organization>
        <name>Instaclustr</name>
        <url>https://instaclustr.com</url>
    </organization>

    <scm>
        <connection>scm:git:git://git@github.com:instaclustr/instaclustr-esop.git</connection>
        <developerConnection>scm:git:ssh://github.com/instaclustr/instaclustr-esop.git</developerConnection>
        <url>git://github.com/instaclustr/instaclustr-esop.git</url>
    </scm>

    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>https://ossrh-staging-api.central.sonatype.com/service/local/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>owasp</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.owasp</groupId>
                        <artifactId>dependency-check-maven</artifactId>
                        <version>${dependency.check.plugin.version}</version>
                        <configuration>
                            <nvdApiKeyEnvironmentVariable>NVD_API_KEY</nvdApiKeyEnvironmentVariable>
                            <dataDirectory>${nvd.data.dir}</dataDirectory>
                            <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cassandra4</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <groups>cassandra4</groups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cassandra5</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <groups>cassandra5</groups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>noCloudTests</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <excludedGroups>cloud-test,azure-test,google-test,s3-test</excludedGroups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cloudTests</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                        <configuration>
                            <groups>cloudTest</groups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>snapshotRepo</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>snapshots</id>
                    <name>Snapshot Repository</name>
                    <url>https://central.sonatype.com/repository/maven-snapshots/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
        <!-- Use this profile when releasing. For example: "mvn clean deploy -P release" -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven.gpg.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus.staging.maven.plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://ossrh-staging-api.central.sonatype.com</nexusUrl>
                            <!--Use "mvn nexus-staging:release -P release" to push from the OSSRH staging repo to Maven Central-->
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>deb</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.vafer</groupId>
                        <artifactId>jdeb</artifactId>
                        <version>${version.jdeb}</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jdeb</goal>
                                </goals>
                                <configuration>
                                    <name>${project.artifactId}</name>
                                    <deb>${outputDirectory}/[[name]]_${project.version}.deb</deb>
                                    <dataSet>
                                        <data>
                                            <src>${outputDirectory}/${project.build.finalName}.jar</src>
                                            <type>file</type>
                                            <mapper>
                                                <type>perm</type>
                                                <prefix>/usr/share/java/</prefix>
                                            </mapper>
                                        </data>
                                        <data>
                                            <src>bin/${project.build.finalName}</src>
                                            <type>file</type>
                                            <mapper>
                                                <type>perm</type>
                                                <filemode>755</filemode>
                                                <prefix>/usr/local/bin/</prefix>
                                            </mapper>
                                        </data>
                                    </dataSet>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>rpm</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>de.dentrassi.maven</groupId>
                        <artifactId>rpm</artifactId>
                        <version>${version.rpm}</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>rpm</goal>
                                </goals>
                                <configuration>
                                    <skip>${skip.packages}</skip>
                                    <packageName>${project.artifactId}</packageName>
                                    <group>Applications/Databases</group>
                                    <packager>${maintainer}</packager>
                                    <skipSigning>true</skipSigning>
                                    <entries>
                                        <entry>
                                            <name>/usr/share/java/${project.build.finalName}.jar</name>
                                            <file>${outputDirectory}/${project.build.finalName}.jar</file>
                                        </entry>
                                        <entry>
                                            <name>/usr/local/bin/${project.build.finalName}</name>
                                            <file>${project.basedir}/bin/${project.build.finalName}</file>
                                            <mode>0755</mode>
                                        </entry>
                                    </entries>
                                    <targetDir>${outputDirectory}</targetDir>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <!-- test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven.source.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <release>11</release>
                    <source>11</source>
                    <target>11</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.shade.plugin.version}</version>
                <configuration>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <transformers>
                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>com.instaclustr.esop.cli.Esop
                            </mainClass>
                        </transformer>

                        <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven.javadoc.plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <skip>${maven.javadoc.skip}</skip>
                            <failOnError>false</failOnError>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <source>11</source>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
