<?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>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
    <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
    <junit.jupiter.version>5.3.1</junit.jupiter.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <payara.micro.version>5.182</payara.micro.version>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <h2.version>1.4.196</h2.version>
  </properties>

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

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-bom</artifactId>
        <version>2.11.1</version>
        <scope>import</scope>
        <type>pom</type>
      </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>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
      <version>2.9.7</version>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.6</version>
      <optional>true</optional>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vavr</groupId>
      <artifactId>vavr</artifactId>
      <version>0.9.2</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>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.jupiter.version}</version>
      <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>
  </dependencies>

  <build>
    <defaultGoal>clean package</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <encoding>${project.build.sourceEncoding}</encoding>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
          <compilerArguments>
            <endorseddirs>${endorsed.dir}</endorseddirs>
          </compilerArguments>
        </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-surefire-plugin</artifactId>
        <version>2.22.1</version>
      </plugin>
    </plugins>
  </build>

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

  <profiles>
    <profile>
      <id>bundle</id>
      <build><!-- ./mvnw -Pbundle # ./mvnw payara-micro:bundle -->
        <defaultGoal>clean package payara-micro:bundle</defaultGoal>
        <plugins>
          <plugin>
            <groupId>fish.payara.maven.plugins</groupId>
            <artifactId>payara-micro-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>bundle</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <payaraVersion>${payara.micro.version}</payaraVersion>
              <commandLineOptions>
                <option>
                  <key>--autobindhttp</key>
                  <value>true</value>
                </option>
                <option>
                  <key>--clusterName</key>
                  <value>app</value>
                </option>
              </commandLineOptions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>start</id>
      <build><!-- ./mvnw -Pstart # ./mvnw payara-micro:start -->
        <defaultGoal>payara-micro:start</defaultGoal>
        <plugins>
          <plugin>
            <groupId>fish.payara.maven.plugins</groupId>
            <artifactId>payara-micro-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <payaraVersion>${payara.micro.version}</payaraVersion>
              <useUberJar>true</useUberJar>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

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