<?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>net.sealake</groupId>
  <artifactId>common-build</artifactId>
  <packaging>pom</packaging>
  <version>1.0.0.RELEASE</version>

  <name>common-build</name>
  <description>Module to centralize common resources and configuration for builds.</description>
  <url>https://github.com/sealake/common-build</url>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>zechengzhao</name>
      <email>zechengzhao@gmail.com</email>
      <organization>sealake.net</organization>
      <organizationUrl>https://sealake.net</organizationUrl>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/sealake/common-build</url>
    <connection>https://github.com/sealake/common-build.git</connection>
    <developerConnection>https://sealake.net</developerConnection>
  </scm>

  <repositories>
    <repository>
      <id>spring-libs-release</id>
      <url>http://repo.spring.io/libs-release</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>spring-milestone</id>
      <url>http://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>spring-libs-snapshot</id>
      <url>http://repo.spring.io/libs-snapshot</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>spring-libs-release</id>
      <url>http://repo.spring.io/libs-release</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>spring-milestone</id>
      <url>http://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>spring-libs-snapshot</id>
      <url>http://repo.spring.io/libs-snapshot</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>oss-github-maven-plugins</id>
      <url>https://raw.github.com/home1-oss/maven-plugins/mvn-repo</url>
      <name>Forked github-maven-plugins that upload faster</name>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <properties>
    <java.version>1.8</java.version>
    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <downloadSources>true</downloadSources>

    <sonar.language>java</sonar.language>
    <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.github.eirslett</groupId>
          <artifactId>frontend-maven-plugin</artifactId>
          <version>1.3</version>
          <configuration>
            <!-- Defaults to https://nodejs.org/dist/ -->
            <nodeDownloadRoot>${frontend.nodeDownloadRoot}</nodeDownloadRoot>
            <!-- Defaults to http://registry.npmjs.org/npm/-/ -->
            <npmDownloadRoot>${frontend.npmDownloadRoot}</npmDownloadRoot>
          </configuration>
        </plugin>
        <plugin>
          <groupId>com.amashchenko.maven.plugin</groupId>
          <artifactId>gitflow-maven-plugin</artifactId>
          <version>1.2.1</version>
        </plugin>
        <plugin>
          <groupId>com.mysema.maven</groupId>
          <artifactId>apt-maven-plugin</artifactId>
          <version>1.1.3</version>
        </plugin>
        <plugin>
          <groupId>com.soebes.maven.plugins</groupId>
          <artifactId>echo-maven-plugin</artifactId>
          <version>0.3.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.18.1</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.12</version>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>1.0.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.5.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.10</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.10.4</version>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.5</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>1.6.7</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>cobertura-maven-plugin</artifactId>
          <version>2.7</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>2.2</version>
        </plugin>
        <plugin>
          <groupId>org.owasp</groupId>
          <artifactId>dependency-check-maven</artifactId>
          <version>1.3.6</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>animal-sniffer-maven-plugin</artifactId>
          <version>1.15</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>findbugs-maven-plugin</artifactId>
          <version>3.0.4</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>jdepend-maven-plugin</artifactId>
          <version>2.0</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>taglist-maven-plugin</artifactId>
          <version>2.4</version>
        </plugin>
        <plugin>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.17</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>6.19</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <artifactId>maven-jxr-plugin</artifactId>
          <version>2.5</version>
        </plugin>
        <!-- maven-pmd-plugin:3.6 depends on net.sourceforge.pmd:pmd:5.3.5 -->
        <!-- maven-pmd-plugin:3.7 depends on net.sourceforge.pmd:pmd:5.5.1 -->
        <plugin>
          <artifactId>maven-pmd-plugin</artifactId>
          <version>3.6</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>2.9</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-report-plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <!-- see: https://github.com/KimJejun/gitflow-maven-plugin -->
      <plugin>
        <groupId>com.amashchenko.maven.plugin</groupId>
        <artifactId>gitflow-maven-plugin</artifactId>
        <configuration>
          <tychoBuild>false</tychoBuild>
          <installProject>false</installProject>
          <verbose>false</verbose>

          <gitFlowConfig>
            <productionBranch>master</productionBranch>
            <developmentBranch>develop</developmentBranch>
            <featureBranchPrefix>feature/</featureBranchPrefix>
            <releaseBranchPrefix>release/</releaseBranchPrefix>
            <hotfixBranchPrefix>hotfix/</hotfixBranchPrefix>
            <supportBranchPrefix>support/</supportBranchPrefix>
            <versionTagPrefix>v</versionTagPrefix>
          </gitFlowConfig>

          <commitMessages>
            <featureStartMessage>updating versions for feature branch</featureStartMessage>
            <featureFinishMessage>updating versions for development branch</featureFinishMessage>

            <hotfixStartMessage>updating versions for hotfix</hotfixStartMessage>
            <hotfixFinishMessage>updating for next development version</hotfixFinishMessage>

            <releaseStartMessage>updating versions for release</releaseStartMessage>
            <releaseFinishMessage>updating for next development version</releaseFinishMessage>

            <tagHotfixMessage>tagging hotfix</tagHotfixMessage>
            <tagReleaseMessage>tagging release</tagReleaseMessage>
          </commitMessages>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>auto-clean-dockerfile</id>
            <phase>clean</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <delete failonerror="false">
                  <fileset dir="${project.basedir}/src/main/docker" includes="Dockerfile"/>
                </delete>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>auto-clean-git-properties</id>
            <phase>clean</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <delete failonerror="false">
                  <fileset dir="${project.basedir}/src/main/resources" includes="git.properties"/>
                </delete>
              </target>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>20020829</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <compilerVersion>${java.version}</compilerVersion>
          <encoding>${project.build.sourceEncoding}</encoding>
          <showDeprecation>true</showDeprecation>
          <showWarnings>true</showWarnings>
          <!-- javac-with-errorprone not working on Eclipse m2e -->
        </configuration>
        <!-- see: https://github.com/google/error-prone -->
        <!-- override plexus-compiler-javac-errorprone's dependency on Error Prone with the latest version -->
        <dependencies>
          <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-javac-errorprone</artifactId>
            <version>2.7</version>
          </dependency>
          <dependency>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_core</artifactId>
            <version>2.0.9</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>${maven.test.skip}</skip>
              <useSystemClassLoader>false</useSystemClassLoader>
              <includes>
                <include>**/*Documentation.java</include>
                <include>**/Test*.java</include>
                <include>**/*Test.java</include>
                <include>**/*TestCase.java</include>
                <include>**/*Tests.java</include>
              </includes>
              <excludes>
                <exclude>**/*IT.java</exclude>
                <exclude>**/deprecated/*.java</exclude>
                <exclude>**/Deprecated*.java</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <skip>${maven.integration-test.skip}</skip>
        </configuration>
        <executions>
          <execution>
            <id>failsafe-integration-test</id>
            <phase>integration-test</phase>
            <goals>
              <goal>integration-test</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/*IT.java</include>
              </includes>
              <excludes>
                <exclude>**/*Documentation.java</exclude>
                <exclude>**/Test*.java</exclude>
                <exclude>**/*Test.java</exclude>
                <exclude>**/*TestCase.java</exclude>
                <exclude>**/*Tests.java</exclude>
                <exclude>**/deprecated/*.java</exclude>
                <exclude>**/Deprecated*.java</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>failsafe-verify</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>filtering-dockerfile</id>
            <phase>process-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.basedir}/src/main/docker</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/resources/docker</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <failOnError>false</failOnError>
          <charset>${project.build.sourceEncoding}</charset>
          <encoding>${project.build.sourceEncoding}</encoding>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <!-- https://maven.apache.org/plugins/maven-source-plugin/test-jar-no-fork-mojo.html-->
              <!-- jar会执行此插件绑定的maven默认生命周期：@Execute( phase = LifecyclePhase.GENERATE_SOURCES ) -->
              <!-- 这里使用jar-no-fork 避免这个问题  -->
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-gpg-plugin</artifactId>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <serverId>ossrh</serverId>
          <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <!-- TODO: need add profiles for different environment -->
  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>
</project>
