<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.springboot</groupId>
  <artifactId>springboot-swagger-starter-root</artifactId>
  <version>0.3.0</version>
  <packaging>pom</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <version.java>${java.version}</version.java>

    <toolisticon.github.organization>toolisticon</toolisticon.github.organization>
    <toolisticon.github.repository>springboot-swagger-starter</toolisticon.github.repository>

    <spring-boot.version>2.3.1.RELEASE</spring-boot.version>
    <springfox.version>3.0.0</springfox.version>
    <javax.validation.version>2.0.1.Final</javax.validation.version>

    <kotlin.version>1.3.72</kotlin.version>
    <project.github.coordinates>toolisticon/springboot-swagger-starter</project.github.coordinates>

    <maven.javadoc.failOnError>false</maven.javadoc.failOnError>
    <!-- disable javadoc linter for JDK8 to not fail on incomplete javadoc -->
    <additionalparam>-Xdoclint:none</additionalparam>
    <jacoco.skip>true</jacoco.skip>

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

  <modules>
    <module>extension</module>
  </modules>

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

  <dependencies>
    <!-- We use kotlin - the libs are default -->
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
      <version>${kotlin.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-reflect</artifactId>
      <version>${kotlin.version}</version>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>clean install</defaultGoal>
    <plugins>
      <plugin>
        <artifactId>kotlin-maven-plugin</artifactId>
        <groupId>org.jetbrains.kotlin</groupId>
        <version>${kotlin.version}</version>
        <configuration>
          <compilerPlugins>
            <plugin>spring</plugin>
          </compilerPlugins>
          <jvmTarget>${java.version}</jvmTarget>
        </configuration>
        <executions>
          <execution>
            <id>kapt</id>
            <goals>
              <goal>kapt</goal>
            </goals>
            <configuration>
              <annotationProcessorPaths>
                <annotationProcessorPath>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-configuration-processor</artifactId>
                  <version>${spring-boot.version}</version>
                </annotationProcessorPath>
              </annotationProcessorPaths>
            </configuration>
          </execution>

          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <sourceDirs>
                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
              </sourceDirs>
            </configuration>
          </execution>
          <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>test-compile</goal>
            </goals>
            <configuration>
              <sourceDirs>
                <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
              </sourceDirs>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-allopen</artifactId>
            <version>${kotlin.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- Coverage -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.5</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <!-- Clean -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>

        <!-- Javadoc -->
        <plugin>
          <groupId>org.jetbrains.dokka</groupId>
          <artifactId>dokka-maven-plugin</artifactId>
          <version>0.10.1</version>
          <executions>
            <execution>
              <phase>package</phase>
              <id>attach-javadocs</id>
              <goals>
                <goal>javadocJar</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <!-- See https://github.com/Kotlin/dokka/issues/294 -->
            <jdkVersion>8</jdkVersion>
            <outputFormat>html</outputFormat>
            <sourceDirectories>
              <dir>${project.basedir}/src/main/kotlin</dir>
            </sourceDirectories>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.2.0</version>
          <executions>
            <execution>
              <phase>generate-sources</phase>
              <goals>
                <goal>add-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>${project.basedir}/src/main/kotlin</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <!-- resources -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.1.0</version>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.2.1</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
              <configuration>
                <attach>true</attach>
                <forceCreation>true</forceCreation>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- Unit Tests -->
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M4</version>
          <configuration>
            <useSystemClassLoader>false</useSystemClassLoader>
            <shutdown>kill</shutdown>
            <runOrder>random</runOrder>
            <excludes>
              <exclude>${pattern.class.itest}</exclude>
              <exclude>${pattern.package.itest}</exclude>
            </excludes>
            <!-- Sets the VM argument line used when unit tests are run. -->
            <!-- prevent the annoying ForkedBooter process from stealing window focus on Mac OS -->
            <argLine>-Djava.awt.headless=true ${argLine} -XX:+StartAttachListener -Xmx1024m -XX:MaxPermSize=256m</argLine>
            <systemPropertyVariables>
              <jgiven.report.dir>${project.build.directory}/jgiven-reports</jgiven.report.dir>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <!-- Install -->
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>

        <!-- gitflow -->
        <plugin>
          <groupId>com.amashchenko.maven.plugin</groupId>
          <artifactId>gitflow-maven-plugin</artifactId>
          <version>1.14.0</version>
          <configuration>
            <gitFlowConfig>
              <productionBranch>master</productionBranch>
              <developmentBranch>develop</developmentBranch>
              <featureBranchPrefix>feature/</featureBranchPrefix>
              <releaseBranchPrefix>release/</releaseBranchPrefix>
              <hotfixBranchPrefix>hotfix/</hotfixBranchPrefix>
              <supportBranchPrefix>support/</supportBranchPrefix>
              <origin>origin</origin>
            </gitFlowConfig>
            <useSnapshotInHotfix>true</useSnapshotInHotfix>
            <useSnapshotInRelease>true</useSnapshotInRelease>
            <keepBranch>false</keepBranch>
            <pushRemote>true</pushRemote>
          </configuration>
        </plugin>

        <!-- To sign the artifacts -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.6</version>
          <configuration>
            <keyname>${gpg.keyname}</keyname>
            <gpgArguments>
              <arg>--batch</arg>
              <arg>--yes</arg>
              <arg>--pinentry-mode</arg>
              <arg>loopback</arg>
            </gpgArguments>
          </configuration>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>


        <!-- Deploy -->
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.0.0-M1</version>
          <configuration>
            <skip>true</skip>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>1.6.8</version>
          <extensions>true</extensions>
          <configuration>
            <autoReleaseAfterClose>true</autoReleaseAfterClose>
            <serverId>ossrh</serverId>
            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          </configuration>
          <executions>
            <execution>
              <id>default-deploy</id>
              <phase>deploy</phase>
              <goals>
                <goal>deploy</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>

    <profile>
      <id>examples</id>
      <activation>
        <property>
          <name>!skipExamples</name>
        </property>
      </activation>
      <modules>
        <module>examples</module>
      </modules>
    </profile>

    <!--
      Profile creating all artifacts: JARs, POMs, Sources, JavaDoc and all signatures.
    -->
    <profile>
      <id>release</id>
      <activation>
        <property>
          <name>release</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <repositories>
    <!-- required for springfox -->
    <repository>
      <id>jcenter</id>
      <name>jcenter</name>
      <url>https://jcenter.bintray.com/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
  <pluginRepositories>
    <!-- required for Dokka (Kotlin javadoc) -->
    <pluginRepository>
      <id>jcenter</id>
      <name>JCenter</name>
      <url>https://jcenter.bintray.com/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>


  <developers>
    <developer>
      <name>Simon Zambrovski</name>
      <roles>
        <role>Product Owner</role>
        <role>Developer</role>
      </roles>
      <organization>Holisticon AG</organization>
      <organizationUrl>https://holisticon.de</organizationUrl>
    </developer>
    <developer>
      <name>Jan Galinski</name>
      <organization>Holisticon AG</organization>
      <organizationUrl>https://holisticon.de</organizationUrl>
      <roles>
        <role>Product Owner</role>
        <role>Developer</role>
      </roles>
    </developer>
  </developers>

  <organization>
    <name>Holisticon AG</name>
    <url>https://holisticon.de/</url>
  </organization>

  <name>${project.artifactId}</name>
  <description>${project.artifactId}</description>
  <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>
  <url>https://github.com/${project.github.coordinates}</url>

  <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>HEAD</tag>
  </scm>

  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/${project.github.coordinates}/issues</url>
  </issueManagement>

  <distributionManagement>
    <site>
      <id>README</id>
      <url>https://github.com/${project.github.coordinates}</url>
    </site>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

</project>
