<?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>
  <version>0.0.1</version>
  <artifactId><%= projectDirectory %></artifactId>
  <packaging>jar</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>
    <junit.jupiter.version>5.3.1</junit.jupiter.version>
    <scala.compat.version>2.12</scala.compat.version>
    <assertj.version>3.11.1</assertj.version>
    <assertk.version>0.12</assertk.version>
    <lombok.version>1.18.6</lombok.version>
    <jgiven.version>0.16.1</jgiven.version>
    <junit4.version>4.12</junit4.version>
    <slf4j.version>1.7.25</slf4j.version>
    <akka.version>2.5.9</akka.version>
    <vavr.version>0.9.2</vavr.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>
    </dependencies>
  </dependencyManagement>

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

  <dependencies>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-actor_${scala.compat.version}</artifactId>
      <version>${akka.version}</version>
    </dependency>

    <dependency>
      <groupId>io.vavr</groupId>
      <artifactId>vavr</artifactId>
      <version>${vavr.version}</version>
    </dependency>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <optional>true</optional>
      <scope>provided</scope>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.2.3</version>
    </dependency>

    <!-- assertj -->
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- hamcrest -->
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>2.1</version>
      <scope>test</scope>
    </dependency>
    <!-- junit 4 -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit4.version}</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>
    <!-- junit 5 -->
    <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>
    <!-- jgiven -->
    <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>

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

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

      <!-- fat jar -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>

        <configuration>
          <finalName>${project.artifactId}-${project.version}-all</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>daggerok.App</mainClass>
            </manifest>
          </archive>
        </configuration>

        <executions>
          <execution>
            <id>assemble-jar-with-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- junit 5 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
      </plugin>

      <!-- jgiven: `mvn verify` -->
      <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>

  <!-- generate findbugs html report `target/site/findbugs.html as part of maven-project-info-report -->
  <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>
                <!-- specify classes for analysis -->
                <onlyAnalyze>*daggerok*</onlyAnalyze>
              </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>

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