<?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>net.leanix.poms</groupId>
    <artifactId>common-parent</artifactId>
    <version>2.0.1</version>
    <packaging>pom</packaging>

    <name>common-parent</name>

    <description>
        General leanIX parent pom to define the versions of used
        libraries and plugins. All common settings are defined here.
    </description>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <url>https://github.com/leanix/leanix-poms</url>

    <organization>
        <name>LeanIX GmbH</name>
        <url>https://www.leanix.net</url>
    </organization>

    <developers>
        <developer>
            <organization>LeanIX GmbH</organization>
            <organizationUrl>https://www.leanix.net</organizationUrl>
        </developer>
    </developers>

    <scm>
        <url>https://github.com/leanix/leanix-poms</url>
        <connection>scm:git:git@github.com:leanix/leanix-poms.git</connection>
        <developerConnection>scm:git:git@github.com:leanix/leanix-poms.git</developerConnection>
    </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <leanix-snapshots.url>http://localhost:8081/nexus/content/repositories/snapshots</leanix-snapshots.url>
        <leanix-releases.url>http://localhost:8081/nexus/content/repositories/releases</leanix-releases.url>

        <gpg.keyname>developer@leanix.net</gpg.keyname>
        <gpg.passphraseServerId>gpg-key-${gpg.keyname}</gpg.passphraseServerId>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <!-- fix versions for standard maven plugins -->

                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.6.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.10</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-eclipse-plugin</artifactId>
                    <version>2.10</version>
                </plugin>
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>1.6</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.2</version>
                </plugin>

                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.3</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>ossrh</serverId>
                        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>

                <!-- used to create source and doc artifacts required to publish a library -->
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.0.5</version>
                                </requireMavenVersion>

                                <!-- ensure fixed plugin versions -->
                                <requirePluginVersions>
                                    <message>Best Practice is to always define plugin versions!</message>
                                    <banLatest>true</banLatest>
                                    <banRelease>true</banRelease>
                                    <banSnapshots>true</banSnapshots>
                                    <phases>clean,deploy,site</phases>
                                    <additionalPlugins>
                                        <additionalPlugin>org.apache.maven.plugins:maven-eclipse-plugin</additionalPlugin>
                                    </additionalPlugins>
                                </requirePluginVersions>

                                <!-- annoyingly, this is too annoying> <DependencyConvergence /> -->
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- used to create source and doc artifacts required to publish a library -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <!-- since maven-javadoc-plugin version 3.0.0 -->
                            <doclint>none</doclint>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>sign</id>
            <!-- needs to be explicitly activated! -->
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- use property gpg.keyname? -->
                                    <keyname>${gpg.keyname}</keyname>
                                    <!-- <passphraseServerId>${gpg.passphraseServerId}</passphraseServerId> -->
                                </configuration>

                                <!-- In your settings.xml file, configure a <server> with an <id> equal to the passphraseServerId given 
                                    above and a <passphrase> equal to the key's passphrase. The <keyname> above can be any string that gpg can use to select the signing 
                                    key. -->
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>deploy-ossrh</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <name>Sonatype snapshots repository</name>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.3</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>deploy-leanix</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>leanix-snapshots</id>
                    <name>LeanIX snapshots repository</name>
                    <url>${leanix-snapshots.url}</url>
                </snapshotRepository>
                <repository>
                    <id>leanix-releases</id>
                    <name>LeanIX releases repository</name>
                    <url>${leanix-releases.url}</url>
                </repository>

                <!-- In your settings.xml file, configure two <server>s with an <id> equal to the ids of snapshotRepository and repository 
                    above. The <server>s must have credentials (<username> and <password>) for the repository server (nexus). -->
            </distributionManagement>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <!-- never, daily, interval:X (where X is in minutes) or always -->
                <updatePolicy>interval:10</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
</project>

