<?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>
  <name>Axon Framework - Gateway Extension - Parent</name>
  <description>Extension for Axon Framework that provides additional gateways.</description>
  <url>https://github.com/holixon/axon-gateway-extension/</url>

  <groupId>io.holixon</groupId>
  <artifactId>axon-gateway-extension-parent</artifactId>
  <version>0.0.4</version>
  <packaging>pom</packaging>

  <modules>
    <module>extension</module>
    <module>extension-spring-boot-autoconfigure</module>
    <module>extension-spring-boot-starter</module>
  </modules>

  <properties>
    <axon.version>4.4.3</axon.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <kotlin.version>1.4.10</kotlin.version>
    <kotlin-logging.version>2.0.3</kotlin-logging.version>

    <java.version>11</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>

    <mockk.version>1.10.2</mockk.version>
    <junit.jupiter.version>5.7.0</junit.jupiter.version>
    <slf4j.version>1.7.30</slf4j.version>
    <log4j.version>2.13.3</log4j.version>
    <dokka.version>1.4.10</dokka.version>

    <springboot.version>2.3.4.RELEASE</springboot.version>

    <!-- Skip KDoc generation by default -->
    <dokka.skip>true</dokka.skip>
    <!-- Skip JaCoCo by default -->
  </properties>

  <dependencyManagement>
    <dependencies>

      <!-- Project dependencies -->
      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>axon-gateway-extension</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>axon-gateway-spring-boot-autoconfigure</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>axon-gateway-spring-boot-starter</artifactId>
        <version>${project.version}</version>
      </dependency>

      <!-- first: Kotlin Import -->
      <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-bom</artifactId>
        <version>${kotlin.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <!-- second: SpringBoot Import (will not mess-up the kotlin.version) -->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${springboot.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <!-- AxonFramework -->
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-configuration</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-modelling</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-messaging</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-test</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>${axon.version}</version>
      </dependency>

      <dependency>
        <groupId>io.mockk</groupId>
        <artifactId>mockk</artifactId>
        <version>${mockk.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.mockk</groupId>
      <artifactId>mockk</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>clean jacoco:prepare-agent install</defaultGoal>
    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    <pluginManagement>
      <plugins>
        <!-- Clean -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>

        <!-- Java Compiler -->
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <encoding>${project.build.sourceEncoding}</encoding>
            <source>${maven.compiler.source}</source>
            <target>${maven.compiler.target}</target>
          </configuration>
          <executions>
            <!-- Replacing default-compile as it is treated specially by maven -->
            <execution>
              <id>default-compile</id>
              <phase>none</phase>
            </execution>
            <!-- Replacing default-testCompile as it is treated specially by maven -->
            <execution>
              <id>default-testCompile</id>
              <phase>none</phase>
            </execution>
            <execution>
              <id>java-compile</id>
              <phase>compile</phase>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>
            <execution>
              <id>java-test-compile</id>
              <phase>test-compile</phase>
              <goals>
                <goal>testCompile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Kotlin Compile -->
        <plugin>
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-maven-plugin</artifactId>
          <version>${kotlin.version}</version>
          <configuration>
            <jvmTarget>1.8</jvmTarget>
            <args>
              <arg>-Xjsr305=strict</arg>
            </args>
            <compilerPlugins>
              <plugin>no-arg</plugin>
              <plugin>spring</plugin>
              <plugin>all-open</plugin>
            </compilerPlugins>
            <pluginOptions>
              <!-- Axon specific classes -->
              <option>all-open:annotation=org.axonframework.modelling.command.AggregateRoot</option>
            </pluginOptions>
          </configuration>
          <executions>
            <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>
            <dependency>
              <groupId>org.jetbrains.kotlin</groupId>
              <artifactId>kotlin-maven-noarg</artifactId>
              <version>${kotlin.version}</version>
            </dependency>
          </dependencies>
        </plugin>

        <!-- Resources -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.2.0</version>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>

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

        <!-- Assembly -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.3.0</version>
          <configuration>
            <descriptorSourceDirectory>assembly</descriptorSourceDirectory>
            <archiverConfig>
              <duplicateBehavior>skip</duplicateBehavior>
            </archiverConfig>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${springboot.version}</version>
        </plugin>

        <!-- Release -->
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
          <configuration>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <localCheckout>true</localCheckout>
            <pushChanges>false</pushChanges>
          </configuration>
        </plugin>

        <!-- Coverage -->
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.6</version>
          <executions>
            <execution>
              <id>pre-unit-test</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>pre-integration-test</id>
              <goals>
                <goal>prepare-agent-integration</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Surefire -->
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.2</version>
          <configuration>
            <useSystemClassLoader>false</useSystemClassLoader>
            <shutdown>kill</shutdown>
            <runOrder>random</runOrder>
            <includes>
              <include>**/*Test.java</include>
              <include>**/*Tests.java</include>
              <include>**/*Test_*.java</include>
              <include>**/*Tests_*.java</include>
            </includes>
            <!-- 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>
            <argLine>${surefireArgLine}</argLine>
            <systemPropertyVariables>
              <slf4j.version>${slf4j.version}</slf4j.version>
              <log4j.version>${log4j.version}</log4j.version>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <!-- Failsafe -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.22.2</version>
        </plugin>

        <!-- KDoc generation -->
        <plugin>
          <groupId>org.jetbrains.dokka</groupId>
          <artifactId>dokka-maven-plugin</artifactId>
          <version>${dokka.version}</version>
          <configuration>
            <!-- Conditional on maven property set per-project -->
            <skip>${dokka.skip}</skip>
            <includes>
              <include>${project.basedir}/src/main/kotlin/packages.md</include>
            </includes>
            <sourceLinks>
              <link>
                <path>${project.basedir}</path>
                <url>https://github.com/holixon/axon-gateway-extension/blob/master</url>
                <lineSuffix>#L</lineSuffix>
              </link>
            </sourceLinks>
            <jdkVersion>${java.version}</jdkVersion>
          </configuration>
          <executions>
            <execution>
              <phase>prepare-package</phase>
              <goals>
                <goal>dokka</goal>
                <goal>javadocJar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- JAR -->
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.2.0</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.2.1</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>package</phase>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Enforcer -->
        <plugin>
          <!-- just to make sure deployed artifacts are always built (and tested) using JDK 8+ -->
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.4.2.jenkins-1</version>
          <executions>
            <execution>
              <id>enforce-java</id>
              <phase>deploy</phase>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireJavaVersion>
                    <version>${java.version}</version>
                  </requireJavaVersion>
                  <requireMavenVersion>
                    <version>3.5</version>
                  </requireMavenVersion>
                </rules>
              </configuration>
            </execution>
          </executions>
        </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>
            <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>2.8.2</version>
          <configuration>
            <skip>true</skip>
          </configuration>
        </plugin>

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

    <!--
    Default build
    -->
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
      </plugin>
    </plugins>

  </build>

  <profiles>

    <!--
    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-source-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.jetbrains.dokka</groupId>
            <artifactId>dokka-maven-plugin</artifactId>
          </plugin>
          <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>

    <profile>
      <!--
      Example module, should be skipped during release
      -->
      <id>example</id>
      <activation>
        <property>
          <name>!skipExamples</name>
        </property>
      </activation>
      <modules>
        <module>example</module>
      </modules>
    </profile>
  </profiles>

  <pluginRepositories>
    <pluginRepository>
      <id>jcenter</id>
      <name>JCenter</name>
      <url>https://jcenter.bintray.com/</url>
    </pluginRepository>
  </pluginRepositories>

  <!-- deploy and release configuration -->
  <distributionManagement>
    <site>
      <id>README</id>
      <url>https://github.com/holixon/axon-gateway-extension</url>
    </site>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <uniqueVersion>true</uniqueVersion>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
      <uniqueVersion>false</uniqueVersion>
    </repository>
  </distributionManagement>

  <scm>
    <connection>scm:git:git://github.com/holixon/axon-gateway-extension.git</connection>
    <developerConnection>scm:git:git@github.com:holixon/axon-gateway-extension.git
    </developerConnection>
    <url>https://github.com/holixon/axon-gateway-extension</url>
    <tag>HEAD</tag>
  </scm>
  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/holixon/axon-gateway-extension/issues</url>
  </issueManagement>


  <developers>
    <developer>
      <name>Simon Zambrovski</name>
      <email>simon.zambrovski@holisticon.de</email>
      <organization>Holisticon AG</organization>
      <organizationUrl>https://holisticon.de</organizationUrl>
      <roles>
        <role>Product Owner</role>
        <role>Developer</role>
      </roles>
    </developer>
  </developers>

  <!-- License Stuff -->
  <inceptionYear>2020</inceptionYear>
  <licenses>
    <license>
      <name>Apache 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>
  <organization>
    <name>Holisticon AG</name>
    <url>https://holixon.io</url>
  </organization>
</project>
