<?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>0.8.2</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>

        <slf4j.version>1.7.6</slf4j.version>

        <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>

        <jgitflow.noDeploy>true</jgitflow.noDeploy>
    </properties>


    <dependencyManagement>

        <dependencies>
            <!-- logging -->

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
                <version>${slf4j.version}</version>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>${slf4j.version}</version>
                <scope>runtime</scope>
            </dependency>

            <!-- used for logging when testing -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>${slf4j.version}</version>
                <scope>test</scope>
            </dependency>

            <!-- redirect java.util.logging used in libraries to slf4j.
                 When adding a dependency on this, you should configure logback
                 to use a LevelChangePropagator to prevent drastic performance loss! -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
                <version>${slf4j.version}</version>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>1.1.2</version>
                <scope>runtime</scope>
            </dependency>

            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.2</version>
                <scope>runtime</scope>
            </dependency>

            <!-- testing -->

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.10</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.easytesting</groupId>
                <artifactId>fest-assert-core</artifactId>
                <version>2.0M10</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>1.9.5</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <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.3</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>2.6</version>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.3</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>2.4.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</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>

                <!-- git flow makes sense only in repositories containing a
                     single maven artefact or when all artefact modules have
                     the same version number. Don't use this elsewhere! -->
                <plugin>
                    <groupId>external.atlassian.jgitflow</groupId>
                    <artifactId>jgitflow-maven-plugin</artifactId>
                    <version>1.0-m5.1</version>
                    <configuration>
                        <allowSnapshots>false</allowSnapshots>
                        <allowUntracked>false</allowUntracked>
                        <noDeploy>${jgitflow.noDeploy}</noDeploy>
                        <pushReleases>true</pushReleases>
                        <enableSshAgent>true</enableSshAgent>
                    </configuration>
                </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>
        </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>
