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

  <parent>
    <groupId>io.holunda.polyflow</groupId>
    <artifactId>polyflow-root</artifactId>
    <version>3.1.8</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>polyflow-parent</artifactId>
  <packaging>pom</packaging>

  <name>POM: ${project.artifactId}</name>
  <description>Polyflow Framework Parent</description>
  <url>https://github.com/holunda-io/camunda-bpm-taskpool/</url>

  <properties>
    <springboot.version>2.6.5</springboot.version>
    <camunda-commons-typed-values.version>7.16.0</camunda-commons-typed-values.version>

    <axon.version>4.5.9</axon.version>
    <axon-kotlin.version>0.2.0</axon-kotlin.version>
    <axon-gateway-extension.version>0.0.5</axon-gateway-extension.version>

    <awaitability.version>4.2.0</awaitability.version>
    <mockito-kotlin.version>4.0.0</mockito-kotlin.version>
    <pattern.class.itest>**/*ITest.*</pattern.class.itest>
    <pattern.package.itest>**/itest/**/*.*</pattern.package.itest>
    <jgiven.version>1.2.0</jgiven.version>

  </properties>

  <modules>
    <module>../../integration/common</module>
    <module>../../integration/camunda-bpm</module>
    <module>../../core/taskpool</module>
    <module>../../core/datapool</module>
    <module>../../view</module>
    <module>../taskpool-dependencies</module>
    <module>../datapool-dependencies</module>
  </modules>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-taskpool-api</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-taskpool-event</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-taskpool-core</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-datapool-api</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-datapool-event</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-datapool-core</artifactId>
        <version>${project.version}</version>
      </dependency>

      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-taskpool-collector</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>camunda-bpm-engine-client</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-tasklist-url-resolver</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-variable-serializer</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-taskpool-sender</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-form-url-resolver</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-datapool-sender</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-view-api</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-view-simple</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holunda.polyflow</groupId>
        <artifactId>polyflow-view-mongo</artifactId>
        <version>${project.version}</version>
      </dependency>

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

      <dependency>
        <!-- second: Import dependency management from SpringBoot (if done prior kotlin, it will overwrite it) -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${springboot.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.camunda.commons</groupId>
        <artifactId>camunda-commons-typed-values</artifactId>
        <version>${camunda-commons-typed-values.version}</version>
      </dependency>

      <!-- Axon Framework -->
      <!-- FIXME: replace with BOM as soon as released -->
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-messaging</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-eventsourcing</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-configuration</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring-boot-starter</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-spring</artifactId>
        <version>${axon.version}</version>
      </dependency>

      <dependency>
        <groupId>org.axonframework.extensions.kotlin</groupId>
        <artifactId>axon-kotlin</artifactId>
        <version>${axon-kotlin.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holixon</groupId>
        <artifactId>axon-gateway-extension</artifactId>
        <version>${axon-gateway-extension.version}</version>
      </dependency>
      <dependency>
        <groupId>io.holixon</groupId>
        <artifactId>axon-gateway-spring-boot-starter</artifactId>
        <version>${axon-gateway-extension.version}</version>
      </dependency>

      <!-- Logging -->
      <dependency>
        <groupId>io.github.microutils</groupId>
        <artifactId>kotlin-logging-jvm</artifactId>
        <version>${kotlin-logging.version}</version>
      </dependency>

      <!-- Testing -->
      <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-test-junit</artifactId>
        <version>${kotlin.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito.kotlin</groupId>
        <artifactId>mockito-kotlin</artifactId>
        <version>${mockito-kotlin.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${springboot.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.axonframework</groupId>
        <artifactId>axon-test</artifactId>
        <version>${axon.version}</version>
      </dependency>
      <dependency>
        <groupId>org.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>${awaitability.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-junit</artifactId>
        <version>${jgiven.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-spring</artifactId>
        <version>${jgiven.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-spring-junit4</artifactId>
        <version>${jgiven.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-html5-report</artifactId>
        <version>${jgiven.version}</version>
        <scope>test</scope>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!-- Kotlin -->
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-reflect</artifactId>
    </dependency>
    <dependency>
      <groupId>io.github.microutils</groupId>
      <artifactId>kotlin-logging-jvm</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>clean jacoco:prepare-agent package</defaultGoal>
    <pluginManagement>
      <plugins>
        <!-- Coverage metering -->
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.7</version>
          <executions>
            <execution>
              <id>pre-unit-test</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                <propertyName>surefireArgLine</propertyName>
              </configuration>
            </execution>
            <execution>
              <id>post-unit-test</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                <excludes>
                  <exclude>${pattern.package.itest}</exclude>
                  <exclude>${pattern.class.itest}</exclude>
                </excludes>
              </configuration>
            </execution>
            <execution>
              <id>pre-integration-test</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
                <propertyName>failsafeArgLine</propertyName>
              </configuration>
            </execution>
            <execution>
              <id>post-integration-test</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                <excludes>
                  <exclude>${pattern.package.itest}</exclude>
                  <exclude>${pattern.class.itest}</exclude>
                </excludes>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <!-- java compiler -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.10.1</version>
          <configuration>
            <encoding>UTF-8</encoding>
            <source>${java.version}</source>
            <target>${java.version}</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>

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

        <plugin>
          <!-- jar -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.2.2</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <!-- for packaging springboot application -->
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${springboot.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <excludes>
              <exclude>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
              </exclude>
              <exclude>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
              </exclude>
              <exclude>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
              </exclude>
              <exclude>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
              </exclude>
            </excludes>
          </configuration>
        </plugin>

        <plugin>
          <!-- for loading and unpacking artifacts -->
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>

        <plugin>
          <groupId>com.coderplus.maven.plugins</groupId>
          <artifactId>copy-rename-maven-plugin</artifactId>
          <version>1.0.1</version>
        </plugin>

        <plugin>
          <!-- kotlin compiler -->
          <artifactId>kotlin-maven-plugin</artifactId>
          <groupId>org.jetbrains.kotlin</groupId>
          <version>${kotlin.version}</version>
          <configuration>
            <jvmTarget>${java.version}</jvmTarget>
            <apiVersion>1.5</apiVersion>
            <languageVersion>1.5</languageVersion>
            <args>
              <arg>-Xjsr305=strict</arg>
            </args>
            <compilerPlugins>
              <plugin>spring</plugin>
              <plugin>jpa</plugin>
              <plugin>no-arg</plugin>
              <plugin>all-open</plugin>
            </compilerPlugins>
            <pluginOptions>
              <option>all-open:annotation=org.axonframework.eventhandling.EventHandler</option>
              <option>all-open:annotation=org.axonframework.queryhandling.QueryHandler</option>
              <option>all-open:annotation=com.tngtech.jgiven.integration.spring.JGivenStage</option>
            </pluginOptions>
          </configuration>
          <executions>
            <!--
            No kapt for a moment
            <execution>
              <id>kapt</id>
              <goals>
                <goal>kapt</goal>
              </goals>
              <configuration>
                <sourceDirs>
                  <sourceDir>${project.basedir}/target/generated-sources/swagger/src/main/java</sourceDir>
                  <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                </sourceDirs>
                <annotationProcessorPaths>
                  <annotationProcessorPath>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-configuration-processor</artifactId>
                    <version>${springboot.version}</version>
                  </annotationProcessorPath>
                </annotationProcessorPaths>
              </configuration>
            </execution>
            -->
            <execution>
              <id>compile</id>
              <goals>
                <goal>compile</goal>
              </goals>
              <configuration>
                <sourceDirs>
                  <sourceDir>${project.basedir}/target/generated-sources/swagger/src/main/java</sourceDir>
                  <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                </sourceDirs>
              </configuration>
            </execution>
            <execution>
              <id>test-compile</id>
              <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>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.2</version>
          <dependencies>
            <dependency>
              <groupId>org.junit.vintage</groupId>
              <artifactId>junit-vintage-engine</artifactId>
              <version>5.8.2</version>
            </dependency>
          </dependencies>
          <configuration>
            <useSystemClassLoader>false</useSystemClassLoader>
            <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 ${surefireArgLine} -XX:+StartAttachListener</argLine>
            <systemPropertyVariables>
              <jgiven.report.dir>${project.build.directory}/jgiven-reports</jgiven.report.dir>
            </systemPropertyVariables>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.22.2</version>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <useSystemClassLoader>false</useSystemClassLoader>
            <includes>
              <include>${pattern.class.itest}</include>
              <include>${pattern.package.itest}</include>
            </includes>
            <!-- Sets the VM argument line used when integration tests are run. -->
            <!-- prevent the annoying ForkedBooter process from stealing window focus on Mac OS -->
            <argLine>-Djava.awt.headless=true ${failsafeArgLine} -XX:+StartAttachListener</argLine>
          </configuration>
        </plugin>

        <!-- javadoc for kotlin -->
        <plugin>
          <groupId>org.jetbrains.dokka</groupId>
          <artifactId>dokka-maven-plugin</artifactId>
          <version>1.6.10</version>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <phase>test</phase>
              <goals>
                <goal>javadocJar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- source from kotlin -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <phase>generate-sources</phase>
              <goals>
                <goal>add-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>src/main/kotlin</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- attach sources -->
        <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>

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

    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-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.jetbrains.dokka</groupId>
            <artifactId>dokka-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
      <pluginRepositories>
        <pluginRepository>
          <id>jcenter</id>
          <name>JCenter</name>
          <url>https://jcenter.bintray.com/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>

    </profile>

    <profile>
      <id>itest</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <properties>
        <skipFrontend>true</skipFrontend>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <!-- Skip Unit test execution on ITest profile run -->
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

</project>
