<?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.dangernoodle</groupId>
    <artifactId>dangernoodle-io-org-pom</artifactId>
    <version>10</version>
    <relativePath />
  </parent>

  <artifactId>dangernoodle-io-build-pom</artifactId>
  <version>5</version>
  <packaging>pom</packaging>

  <name>${project.artifactId}</name>
  <url>https://github.com/dangernoodle-io/dangernoodle-io-build-pom</url>
  <description>parent pom for dangernoodle.io builds</description>

  <properties>
    <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.jar.name>${project.artifactId}-${project.version}.jar</project.jar.name>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <logback.defaultLogLevel>off</logback.defaultLogLevel>

    <it.slf4j.defaultLogLevel>off</it.slf4j.defaultLogLevel>
    <ut.slf4j.defaultLogLevel>off</ut.slf4j.defaultLogLevel>

    <!-- plugin versions -->
    <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
    <coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
    <docker-maven-plugin.version>0.25.2</docker-maven-plugin.version>
    <jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
    <maven-compiler.version>3.5.1</maven-compiler.version>
    <maven-failsafe.version>${maven-surefire.version}</maven-failsafe.version>
    <maven-jar.version>3.0.2</maven-jar.version>
    <maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
    <maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>
    <maven-scm-publish-plugin.version>1.1</maven-scm-publish-plugin.version>
    <maven-shade-plugin.version>3.0.0</maven-shade-plugin.version>
    <maven-source.version>3.0.1</maven-source.version>
    <maven-surefire.version>2.21.0</maven-surefire.version>

    <!-- plugin dependency versions -->
    <junit-platform.version>1.2.0</junit-platform.version>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler.version}</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <compilerArgs>
              <arg>-Xlint:all,-processing</arg>
            </compilerArgs>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.junit.platform</groupId>
              <artifactId>junit-platform-surefire-provider</artifactId>
              <version>${junit-platform.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <excludes>
              <exclude>Abstract*.java</exclude>
            </excludes>
            <systemPropertyVariables combine.children="append">
              <default.logback.level>${logback.defaultLogLevel}</default.logback.level>
              <org.slf4j.simpleLogger.defaultLogLevel>${ut.slf4j.defaultLogLevel}</org.slf4j.simpleLogger.defaultLogLevel>
            </systemPropertyVariables>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-failsafe.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.junit.platform</groupId>
              <artifactId>junit-platform-surefire-provider</artifactId>
              <version>${junit-platform.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <excludes>
              <exclude>Abstract*.java</exclude>
            </excludes>
            <systemPropertyVariables combine.children="append">
              <default.logback.level>${logback.defaultLogLevel}</default.logback.level>
              <org.slf4j.simpleLogger.defaultLogLevel>${it.slf4j.defaultLogLevel}</org.slf4j.simpleLogger.defaultLogLevel>
            </systemPropertyVariables>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar.version}</version>
          <executions>
            <execution>
              <id>test-jar</id>
              <goals>
                <goal>test-jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
          <configuration>
            <additionalparam>-Xdoclint:none</additionalparam>
            <nohelp>true</nohelp>
            <header>${javadoc.project.artifactId} - ${project.version}</header>
            <footer>${javadoc.project.artifactId} - ${project.version}</footer>
            <doctitle>${javadoc.project.artifactId} - ${project.version}</doctitle>
            <windowtitle>${javadoc.project.artifactId} - ${project.version}</windowtitle>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven-shade-plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>shade</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>${docker-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>package</id>
              <phase>package</phase>
              <goals>
                <goal>build</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${build-helper-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>add-test-source</id>
              <phase>generate-test-sources</phase>
              <goals>
                <goal>add-test-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>src/integration/java</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <scm>
    <connection>scm:git:git@github.com:dangernoodle-io/dangernoodle-io-build-pom.git</connection>
    <developerConnection>scm:git:git@github.com:dangernoodle-io/dangernoodle-io-build-pom.git</developerConnection>
    <url>https://github.com/dangernoodle-io/dangernoodle-io-build-pom</url>
    <tag>dangernoodle-io-build-pom-5</tag>
  </scm>

  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/dangernoodle-io/dangernoodle-io-build-pom/issues</url>
  </issueManagement>

  <repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
  </repositories>

  <profiles>
    <profile>
      <id>attach-src-docs</id>
      <activation>
        <property>
          <name>env.JENKINS_HOME</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-source-plugin</artifactId>
              <executions>
                <execution>
                  <id>attach-sources</id>
                  <goals>
                    <goal>jar-no-fork</goal>
                    <goal>test-jar-no-fork</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <executions>
                <execution>
                  <id>attach-javadocs</id>
                  <goals>
                    <goal>jar</goal>
                  </goals>
                  <configuration>
                    <outputDirectory>${project.reporting.outputDirectory}/apidocs</outputDirectory>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>coverage</id>
      <activation>
        <property>
          <name>env.JENKINS_HOME</name>
        </property>
      </activation>
      <properties>
        <jacoco.haltOnFailure>true</jacoco.haltOnFailure>
        <dangernoodle.coveralls.token>${env.COVERALLS_REPO_TOKEN}</dangernoodle.coveralls.token>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <version>${jacoco-maven-plugin.version}</version>
              <executions>
                <execution>
                  <id>default-prepare-agent</id>
                  <goals>
                    <goal>prepare-agent</goal>
                  </goals>
                </execution>
                <execution>
                  <id>default-prepare-agent-integration</id>
                  <goals>
                    <goal>prepare-agent-integration</goal>
                  </goals>
                </execution>
                <execution>
                  <id>default-report</id>
                  <goals>
                    <goal>report</goal>
                  </goals>
                </execution>
                <execution>
                  <id>default-report-integration</id>
                  <goals>
                    <goal>report-integration</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.eluder.coveralls</groupId>
              <artifactId>coveralls-maven-plugin</artifactId>
              <version>${coveralls-maven-plugin.version}</version>
              <configuration>
                <repoToken>${dangernoodle.coveralls.token}</repoToken>
                <serviceName>travis-pro</serviceName>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>integration-tests</id>
      <activation>
        <property>
          <name>env.JENKINS_HOME</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-failsafe-plugin</artifactId>
              <configuration>
                <systemPropertyVariables>
                  <org.slf4j.simpleLogger.defaultLogLevel>warn</org.slf4j.simpleLogger.defaultLogLevel>
                </systemPropertyVariables>
              </configuration>
              <executions>
                <execution>
                  <id>integration-test</id>
                  <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <activation>
        <property>
          <name>env.IS_M2RELEASEBUILD</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <executions>
                <execution>
                  <id>site-resources</id>
                  <!-- phase: package -->
                  <phase>none</phase>
                  <goals>
                    <goal>copy-resources</goal>
                  </goals>
                  <configuration>
                    <outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
                    <resources>
                      <resource>
                        <directory>src/main/site</directory>
                      </resource>
                    </resources>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-javadoc-plugin</artifactId>
              <executions>
                <execution>
                  <id>site-javadoc</id>
                  <!-- phase: package -->
                  <phase>none</phase>
                  <goals>
                    <goal>javadoc-no-fork</goal>
                  </goals>
                  <configuration>
                    <includeDependencySources>true</includeDependencySources>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-scm-publish-plugin</artifactId>
              <version>${maven-scm-publish-plugin.version}</version>
              <configuration>
                <checkinComment>- publishing javadoc for ${project.version}</checkinComment>
                <content>${project.reporting.outputDirectory}</content>
                <pubScmUrl>${javadoc.site.scm}</pubScmUrl>
                <scmBranch>gh-pages</scmBranch>
                <tryUpdate>true</tryUpdate>
              </configuration>
              <executions>
                <execution>
                  <id>publish-javadoc</id>
                  <!-- phase: deploy -->
                  <phase>none</phase>
                  <goals>
                    <goal>publish-scm</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

</project>
