<?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>com.github.daggerok</groupId>
  <artifactId><%= projectDirectory %></artifactId>
  <version>0.0.1</version>
  <packaging>war</packaging>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <encoding>UTF-8</encoding>
    <archetype.encoding>${encoding}</archetype.encoding>
    <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
    <project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
    <project.resources.outputEncoding>${encoding}</project.resources.outputEncoding>
    <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <thorntail.version>2.2.1.Final</thorntail.version>
    <junit.jupiter.version>5.3.1</junit.jupiter.version>
    <jgiven.version>0.16.1</jgiven.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>bom-all</artifactId>
        <version>${thorntail.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-bom</artifactId>
        <version>2.11.1</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>

      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.jupiter.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <!--<dependency>
      <groupId>org.webjars</groupId>
      <artifactId>material-design-icons</artifactId>
      <version>3.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.webjars</groupId>
      <artifactId>materializecss</artifactId>
      <version>1.0.0</version>
    </dependency>-->
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>8.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.thorntail</groupId>
      <artifactId>microprofile</artifactId>
      <exclusions>
        <exclusion>
          <groupId>io.thorntail</groupId>
          <artifactId>microprofile-opentracing</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.thorntail</groupId>
      <artifactId>jsonp</artifactId>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.4.196</version>
    </dependency>

    <!-- in java we trust and believe -->
    <dependency>
      <groupId>io.vavr</groupId>
      <artifactId>vavr</artifactId>
      <version>0.9.2</version>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.6</version>
      <optional>true</optional>
      <scope>provided</scope>
    </dependency>
    <!--<dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.25</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.2.3</version>
    </dependency>-->

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.11.1</version>
      <scope>test</scope>
    </dependency>
    <!-- hamcrest -->
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>2.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apiguardian</groupId>
      <artifactId>apiguardian-api</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>com.tngtech.jgiven</groupId>
      <artifactId>jgiven-html5-report</artifactId>
      <version>${jgiven.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-junit5</artifactId>
      <version>${jgiven.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>clean package</defaultGoal>
    <finalName>${project.artifactId}</finalName>

    <plugins>
      <plugin>
        <groupId>io.thorntail</groupId>
        <artifactId>thorntail-maven-plugin</artifactId>
        <version>${thorntail.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>package</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <debugPort>5005</debugPort>
          <fractionDetectMode>force</fractionDetectMode>
          <executable>true</executable>
          <properties>
            <!--<thorntail.bind.address>0.0.0.0</thorntail.bind.address>-->
            <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
          </properties>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.2</version>

        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>

        <configuration>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
        </configuration>

        <executions>
          <execution>
            <id>default-compile</id><!-- Replacing default-compile as it is treated specially by maven -->
            <phase>none</phase>
          </execution>
          <execution>
            <id>default-testCompile</id><!-- Replacing default-testCompile as it is treated specially by maven -->
            <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>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
      </plugin>

      <plugin>
        <groupId>com.tngtech.jgiven</groupId>
        <artifactId>jgiven-maven-plugin</artifactId>
        <version>${jgiven.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <format>html</format>
          <outputDirectory>${project.build.directory}/jgiven-report</outputDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>

        <configuration>
          <reportPlugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>findbugs-maven-plugin</artifactId>
              <configuration>
                <onlyAnalyze>*daggerok*</onlyAnalyze><!-- specify classes for analysis -->
              </configuration>
            </plugin>
          </reportPlugins>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>3.0.5</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.0.0</version>

        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

  <repositories>
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Maven Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </repository>

    <repository>
      <id>jcenter.bintray.com</id>
      <url>https://jcenter.bintray.com</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Maven Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <distributionManagement>
    <repository>
      <id>local-repo</id>
      <url>file://${project.basedir}/target/local-repo</url>
    </repository>
  </distributionManagement>

  <profiles>
    <profile>
      <id>docker</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.dkanejs.maven.plugins</groupId>
            <artifactId>docker-compose-maven-plugin</artifactId>
            <version>2.2.0</version>
            <executions>
              <execution>
                <id>up</id>
                <phase>verify</phase>
                <goals>
                  <goal>up</goal>
                </goals>
              </execution>
              <execution>
                <id>down</id>
                <phase>verify</phase>
                <goals>
                  <goal>down</goal>
                </goals>
              </execution>
              <execution>
                <id>help</id>
                <phase>verify</phase>
                <goals>
                  <goal>help</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <build>true</build>
              <composeFile>${project.basedir}/docker-compose-maven.yaml</composeFile>
              <detachedMode>true</detachedMode>
              <removeImages>true</removeImages>
              <removeImagesType>local</removeImagesType>
              <removeOrphans>true</removeOrphans>
              <removeVolumes>true</removeVolumes>
              <!--<verbose>true</verbose>-->
              <detail>true</detail>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>docs</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>1.5.7.1</version>

            <dependencies>
              <dependency>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctorj-pdf</artifactId>
                <version>1.5.0-alpha.16</version>
              </dependency>
              <dependency>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctorj-diagram</artifactId>
                <version>1.5.10</version>
              </dependency>
            </dependencies>

            <configuration>
              <outputDirectory>target/generated-docs</outputDirectory>
              <sourceDirectory>docs</sourceDirectory>
              <relativeBaseDir>true</relativeBaseDir>
              <headerFooter>true</headerFooter>
              <imagesDir>.</imagesDir><!-- Don't know why, but yes - use base sources dir... -->
              <attributes>
                <headerFooter>true</headerFooter>
                <toc>left</toc>
                <linkcss>false</linkcss>
                <doctype>book</doctype>
                <ruby>erubis</ruby>
                <encoding>${project.build.sourceEncoding}</encoding>
                <linkattrs>true</linkattrs>
                <numbered>false</numbered>
                <sectanchors>true</sectanchors>
                <sectlink>true</sectlink>
                <idprefix/>
                <docinfo1/>
                <icons>font</icons>
                <idseparator>-</idseparator>
                <setanchors>true</setanchors>
                <toc-title>Table of Contents</toc-title>
                <project-name>${project.artifactId}</project-name>
                <root-project-name>${project.artifactId}</root-project-name>
                <project-version>${project.version}</project-version>
                <github-url>https://github.com/daggerok/${project.artifactId}</github-url>
              </attributes>
            </configuration>

            <executions>
              <execution>
                <id>output-html</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <backend>html</backend>
                  <sourceHighlighter>highlightjs</sourceHighlighter>
                </configuration>
              </execution>

              <execution>
                <id>output-docbook</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <backend>docbook</backend>
                </configuration>
              </execution>

              <execution>
                <id>output-pdf-doc</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>process-asciidoc</goal>
                </goals>
                <configuration>
                  <backend>pdf</backend>
                  <sourceHighlighter>coderay</sourceHighlighter>
                  <requires>
                    <require>asciidoctor-diagram</require>
                    <require>coderay</require>
                  </requires>
                  <attributes>
                    <icons>font</icons>
                    <pagenums/>
                  </attributes>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>

        <defaultGoal>clean process-resources</defaultGoal>
      </build>
    </profile>
  </profiles>
</project>
