<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>cassandra-ldap-parent</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    
    <modules>
        <module>base</module>
        <module>cassandra-2.2</module>
        <module>cassandra-3.0</module>
        <module>cassandra-3.11</module>
        <module>cassandra-4.0</module>
    </modules>
    
    <name>Cassandra LDAP Authenticator parent</name>
    <description>Cassadra LDAP plugin parent</description>
    <url>https://github.com/instaclustr/cassandra-ldap</url>
    
    <inceptionYear>2020</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>Various</name>
            <organization>Instaclustr</organization>
            <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/cassandra-ldap.git</connection>
        <developerConnection>scm:git:ssh://github.com/instaclustr/cassandra-ldap.git</developerConnection>
        <url>git://github.com/instaclustr/cassandra-ldap.git</url>
    </scm>
    
    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
    
    <properties>
        <maintainer>Stefan Miklosovic &lt;stefan.miklosovic@instaclustr.com&gt;</maintainer>  
        <maven.javadoc.plugin.version>3.1.1</maven.javadoc.plugin.version>
        <maven.source.plugin.version>3.1.0</maven.source.plugin.version>
        <maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
        <maven.jar.plugin.version>3.2.0</maven.jar.plugin.version>
        <maven.deploy.plugin.version>2.8.2</maven.deploy.plugin.version>
        <nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version>
        <maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
        <maven.surefire.plugin>2.22.2</maven.surefire.plugin>
        <maven.docker.plugin>0.34.1</maven.docker.plugin>
        <maven.build.helper.plugin>3.0.0</maven.build.helper.plugin>
        <version.jdeb>1.8</version.jdeb>
        <version.rpm>1.5.0</version.rpm>
        
        <deploy.skip.parent>true</deploy.skip.parent>
        <outputDirectory>${project.build.directory}</outputDirectory>
        
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>${maven.deploy.plugin.version}</version>
                <configuration>
                    <skip>${deploy.skip.parent}</skip>
                </configuration>
                <inherited>false</inherited>
            </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>
                    </execution>
                </executions>
            </plugin>
            <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-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin}</version>
                <configuration>
                    <excludes>
                        <exclude>**/*IntegrationTest</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <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>
                        <outputDirectory>${outputDirectory}</outputDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <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>${project.build.directory}/${project.build.finalName}.jar</src>
                                        <type>file</type>
                                        <mapper>
                                            <type>perm</type>
                                            <prefix>/usr/share/cassandra/lib</prefix>
                                        </mapper>
                                    </data>
                                    <data>
                                        <src>${project.basedir}/../conf/ldap.properties</src>
                                        <type>file</type>
                                        <mapper>
                                            <type>perm</type>
                                            <prefix>/etc/cassandra/ldap.properties</prefix>
                                        </mapper>
                                    </data>
                                </dataSet>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>de.dentrassi.maven</groupId>
                    <artifactId>rpm</artifactId>
                    <version>${version.rpm}</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>rpm</goal>
                            </goals>
                            <configuration>
                                <packageName>${project.artifactId}</packageName>
                                <group>Applications/Databases</group>
                                <packager>${maintainer}</packager>
                                <skipSigning>true</skipSigning>
                                <entries>
                                    <entry>
                                        <name>/usr/share/cassandra/lib/${project.build.finalName}.jar</name>
                                        <file>${project.build.directory}/${project.build.finalName}.jar</file>
                                    </entry>
                                    <entry>
                                        <name>/etc/cassandra/ldap.properties</name>
                                        <file>${project.basedir}/../conf/ldap.properties</file>
                                    </entry>
                                </entries>
                                <targetDir>${outputDirectory}</targetDir>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    
    <profiles>
        <profile>
            <id>it</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>io.fabric8</groupId>
                            <artifactId>docker-maven-plugin</artifactId>
                            <version>${maven.docker.plugin}</version>
                            <executions>
                                <execution>
                                    <id>container-start</id>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>start</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>container-stop</id>
                                    <phase>post-integration-test</phase>
                                    <goals>
                                        <goal>stop</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <images>
                                    <image>
                                        <alias>ldap-it-server</alias>
                                        <name>osixia/openldap</name>
                                        <run>
                                            <env>
                                                <LDAP_ADMIN_PASSWORD>admin</LDAP_ADMIN_PASSWORD>
                                            </env>
                                            <ports>
                                                <port>127.0.0.1:389:389</port>
                                            </ports>
                                            <wait>
                                                <log>LDAP server is started</log>
                                                <time>5000</time>
                                                <tcp>
                                                    <ports>
                                                        <port>389</port>
                                                    </ports>
                                                </tcp>
                                            </wait>
                                        </run>
                                    </image>
                                </images>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven.surefire.plugin}</version>
                        <executions>
                            <execution>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>none</exclude>
                                    </excludes>
                                    <includes>
                                        <include>**/*IntegrationTest</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </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://oss.sonatype.org/</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>
    </profiles>
</project>
