<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>io.toolisticon.maven</groupId>
  <artifactId>maven-oss-parent</artifactId>
  <name>${project.artifactId}</name>
  <version>0.4</version>
  <packaging>pom</packaging>

  <description>
    Parent pom for all holisticon OSS projects. Use this instead of sonatype/oss-parent for common properties and
    pre-configured modules.
  </description>

  <organization>
    <name>Holisticon AG</name>
    <url>http://www.holisticon.de/</url>
  </organization>
  <url>https://github.com/${project.github.coordinates}</url>

  <developers>
    <developer>
      <id>jangalinski</id>
      <name>Jan Galinski</name>
      <organization>${project.organization.name}</organization>
    </developer>
    <developer>
      <id>zambrovski</id>
      <name>Simon Zambrovski</name>
      <organization>${project.organization.name}</organization>
    </developer>

  </developers>

  <properties>
    <!-- must overwrite - use your organization and repo! -->
    <project.github.organization>toolisticon</project.github.organization>
    <project.github.repository>${project.name}</project.github.repository>

    <!-- overwrite these properties in your pom.xml if needed -->
    <java.version>1.8</java.version>
    <maven.minor.version>3.5</maven.minor.version>
    <maven.version>${maven.minor.version}.0</maven.version>

    <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
    <kotlin.version>1.1.61</kotlin.version>

    <spring-boot.version>1.5.8.RELEASE</spring-boot.version>

    <skipDeploy>false</skipDeploy>
    <skipITests>true</skipITests>

    <pattern.package.itest>**/itest/*.java</pattern.package.itest>
    <pattern.class.itest>**/*ITest.java</pattern.class.itest>

    <!-- normally you won't overwrite the properties below -->
    <project.github.coordinates>${project.github.organization}/${project.github.repository}</project.github.coordinates>
    <encoding>UTF-8</encoding>
    <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
    <project.build.resourceEncoding>${encoding}</project.build.resourceEncoding>

    <sonatype-oss-dist-mgmt-snapshots-url>
      https://oss.sonatype.org/content/repositories/snapshots/
    </sonatype-oss-dist-mgmt-snapshots-url>
  </properties>

  <build>
    <defaultGoal>clean install</defaultGoal>

    <!--
                                  _             _
        ___ ___  _ __ ___   _ __ | |_   _  __ _(_)_ __  ___
       / __/ _ \| '__/ _ \ | '_ \| | | | |/ _` | | '_ \/ __|
      | (_| (_) | | |  __/ | |_) | | |_| | (_| | | | | \__ \
       \___\___/|_|  \___| | .__/|_|\__,_|\__, |_|_| |_|___/
                           |_|            |___/

      define plugins in latest version - alphabetical order

    // -->
    <pluginManagement>
      <plugins>
        <!-- clean -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <!-- compile -->
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
          <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
          </configuration>
        </plugin>
        <!-- dependency -->
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <!-- deploy -->
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
          <configuration>
            <skip>${skipDeploy}</skip>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <!-- help -->
        <plugin>
          <artifactId>maven-help-plugin</artifactId>
          <version>2.2</version>
        </plugin>
        <!-- install -->
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <!-- jar -->
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>
        <!-- release -->
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
        </plugin>
        <!-- resources -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <!-- shade -->
        <plugin>
          <artifactId>maven-shade-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- site -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.6</version>
        </plugin>
        <!-- surefire -->
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <!-- version -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>2.5</version>
        </plugin>
        <!-- sources -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>
        <!-- javadoc -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.10.4</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
          <execution>
            <id>enforce-maven</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>${maven.minor.version}</version>
                </requireMavenVersion>
                <requireJavaVersion>
                  <version>${java.version}</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!-- private profile, only include during parent development -->
      <id>_maven-oss-parent-examples</id>
      <modules>
        <module>examples</module>
      </modules>
    </profile>

    <!--
          _            _           _             _
         | |_ ___  ___| |_   _ __ | |_   _  __ _(_)_ __  ___
         | __/ _ \/ __| __| | '_ \| | | | |/ _` | | '_ \/ __|
         | ||  __/\__ \ |_  | |_) | | |_| | (_| | | | | \__ \
          \__\___||___/\__| | .__/|_|\__,_|\__, |_|_| |_|___/
                            |_|            |___/

         The testing profile is automatically activated once a src/test/java dir is found on the project.

    // -->
    <profile>
      <id>auto-testing-java</id>
      <activation>
        <file>
          <exists>src/test/java</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <runOrder>random</runOrder>
              <excludes>
                <exclude>${pattern.class.itest}</exclude>
                <exclude>${pattern.package.itest}</exclude>
              </excludes>
              <!-- prevent the annoying ForkedBooter process from stealing window focus on Mac OS -->
              <argLine>-Djava.awt.headless=true</argLine>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <skipTests>${skipITests}</skipTests>
              <includes>
                <include>${pattern.class.itest}</include>
                <include>${pattern.package.itest}</include>
              </includes>
              <!-- prevent the annoying ForkedBooter process from stealing window focus on Mac OS -->
              <argLine>-Djava.awt.headless=true</argLine>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
         _         _   _ _
        | | _____ | |_| (_)_ __
        | |/ / _ \| __| | | '_ \
        |   < (_) | |_| | | | | | |_|\_\___/ \__|_|_|_| |_| activate kotlin compiler when src/main/kotlin is present //-->
    <profile>
      <id>auto-kotlin</id>
      <activation>
        <file>
          <exists>src/main/kotlin</exists>
        </file>
      </activation>
      <properties>
        <project.build.sourceDirectory>src/main/kotlin</project.build.sourceDirectory>
        <project.build.testSourceDirectory>src/test/kotlin</project.build.testSourceDirectory>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-stdlib-jre8</artifactId>
          <version>${kotlin.version}</version>
        </dependency>
        <dependency>
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-reflect</artifactId>
          <version>${kotlin.version}</version>
        </dependency>
        <dependency>
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-test</artifactId>
          <version>${kotlin.version}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <version>${kotlin.version}</version>
            <configuration>
              <compilerPlugins>
                <plugin>spring</plugin>
              </compilerPlugins>
              <jvmTarget>${java.version}</jvmTarget>
            </configuration>
            <executions>
              <execution>
                <id>compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
              </execution>
              <execution>
                <id>test-compile</id>
                <phase>test-compile</phase>
                <goals>
                  <goal>test-compile</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-allopen</artifactId>
                <version>${kotlin.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
                         _                   _                 _
          ___ _ __  _ __(_)_ __   __ _      | |__   ___   ___ | |_
         / __| '_ \| '__| | '_ \ / _` |_____| '_ \ / _ \ / _ \| __|
         \__ \ |_) | |  | | | | | (_| |_____| |_) | (_) | (_) | |_
         |___/ .__/|_|  |_|_| |_|\__, |     |_.__/ \___/ \___/ \__|
             |_|                 |___/

         use spring boot when 'application.yml' is present

    //-->
    <profile>
      <id>auto-spring-boot</id>
      <activation>
        <file>
          <exists>src/main/resources/application.yml</exists>
        </file>
      </activation>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <scope>import</scope>
            <type>pom</type>
          </dependency>
        </dependencies>
      </dependencyManagement>

      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring-boot.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>repackage</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <layout>ZIP</layout>
            </configuration>
          </plugin>
        </plugins>
      </build>

    </profile>

    <!-- do not skip itests in integration-test phase-->
    <profile>
      <id>integration-test</id>
      <properties>
        <skipITests>false</skipITests>
      </properties>
    </profile>

    <profile>
      <id>info</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-help-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

  <repositories>
    <repository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <distributionManagement>
    <snapshotRepository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>${sonatype-oss-dist-mgmt-snapshots-url}</url>
    </snapshotRepository>
    <repository>
      <id>sonatype-nexus-staging</id>
      <name>Nexus Release Repository</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <licenses>
    <license>
      <name>Revised BSD License</name>
      <url>
        http://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_.28.22Revised_BSD_License.22.2C_.22New_BSD_License.22.2C_or_.22Modified_BSD_License.22.29
      </url>
      <comments>see LICENSE.txt</comments>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <issueManagement>
    <system>GitHub Issues</system>
    <url>${project.url}/issues</url>
  </issueManagement>

  <scm>
    <connection>scm:git:git@github.com:${project.github.coordinates}.git</connection>
    <developerConnection>scm:git:git@github.com:${project.github.coordinates}.git</developerConnection>
    <url>git@github.com:/${project.github.coordinates}.git</url>
    <tag>maven-oss-parent-0.4</tag>
  </scm>

</project>
