<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>io.github.zlika</groupId>
  <artifactId>reproducible-build-maven-plugin</artifactId>
  <version>0.3</version>
  <packaging>maven-plugin</packaging>

  <name>Reproducible Build Maven Plugin</name>
  <description>This Plug-In allows to generate byte-for-byte reproducible artifacts</description>
  <url>http://zlika.github.io/reproducible-build-maven-plugin</url>
  
  <inceptionYear>2015</inceptionYear>
  <licenses>
    <license>
      <name>Apache 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  
  <developers>
    <developer>
      <name>Thomas Lorblanchès</name>
      <email>zlika_ese@hotmail.com</email>
    </developer>
  </developers>
  
  <scm>
    <connection>scm:git:git@github.com:Zlika/reproducible-build-maven-plugin.git</connection>
    <developerConnection>scm:git:git@github.com:Zlika/reproducible-build-maven-plugin.git</developerConnection>
    <url>https://github.com/Zlika/reproducible-build-maven-plugin</url>
    <tag>reproducible-build-maven-plugin-0.3</tag>
  </scm>
  
  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/Zlika/reproducible-build-maven-plugin/issues</url>
  </issueManagement>
  
  <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>
    <site>
      <id>github-project-site</id>
      <url>gitsite:git@github.com/Zlika/reproducible-build-maven-plugin.git</url>
    </site>
  </distributionManagement>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    
    <!-- Maven plugin versions -->
    <coveralls-maven-plugin.version>4.0.0</coveralls-maven-plugin.version>
    <findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
    <jacoco-maven-plugin.version>0.7.9</jacoco-maven-plugin.version>
    <maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
    <maven-clean-plugin.version>2.6.1</maven-clean-plugin.version>
    <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
    <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
    <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
    <maven-install-plugin.version>2.5.2</maven-install-plugin.version>
    <maven-invoker-plugin.version>2.0.0</maven-invoker-plugin.version>
    <maven-jar-plugin.version>2.6</maven-jar-plugin.version>
    <maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version>
    <maven-plugin-plugin.version>3.4</maven-plugin-plugin.version>
    <maven-project-info-reports-plugin.version>2.8</maven-project-info-reports-plugin.version>
    <maven-release-plugin.version>2.5.2</maven-release-plugin.version>
    <maven-resources-plugin.version>2.7</maven-resources-plugin.version>
    <maven-scm.version>1.9.4</maven-scm.version>
    <maven-source-plugin.version>2.4</maven-source-plugin.version>
    <maven-site-plugin.version>3.4</maven-site-plugin.version>
    <maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
    <maven-surefire-report-plugin.version>2.18.1</maven-surefire-report-plugin.version>
    <wagon-gitsite.version>0.3.1</wagon-gitsite.version>
    
    <!-- Dependency versions -->
    <commons-compress.version>1.14</commons-compress.version>
    <junit.version>4.12</junit.version>
    <maven-plugin-annotations.version>3.4</maven-plugin-annotations.version>
    <maven-plugin-api.version>3.3.3</maven-plugin-api.version>
    <plexus-utils.version>3.0.22</plexus-utils.version>
    
  </properties>

  <dependencies>
  
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${maven-plugin-api.version}</version>
    </dependency>
    
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>${maven-plugin-annotations.version}</version>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.codehaus.plexus</groupId>
      <artifactId>plexus-utils</artifactId>
      <version>${plexus-utils.version}</version>
    </dependency>
    
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>${commons-compress.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.tukaani</groupId>
          <artifactId>xz</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.brotli</groupId>
          <artifactId>dec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    
  </dependencies>

  <build>
  
    <!-- Extensions to deploy site documentation to Github using Github's pages system.
         Cf. http://khuxtable.github.io/wagon-gitsite/ -->
    <extensions>
      <extension>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-provider-gitexe</artifactId>
        <version>${maven-scm.version}</version>
      </extension>
      <extension>
        <groupId>org.apache.maven.scm</groupId>
        <artifactId>maven-scm-manager-plexus</artifactId>
        <version>${maven-scm.version}</version>
      </extension>
      <extension>
        <groupId>org.kathrynhuxtable.maven.wagon</groupId>
        <artifactId>wagon-gitsite</artifactId>
        <version>${wagon-gitsite.version}</version>
      </extension>
    </extensions>

    <pluginManagement>
      <plugins>
      
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </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-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>
        
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${maven-release-plugin.version}</version>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <useReleaseProfile>false</useReleaseProfile>
            <releaseProfiles>release</releaseProfiles>
            <goals>deploy</goals>
          </configuration>
        </plugin>
        
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>
        
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
        </plugin>
        
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco-maven-plugin.version}</version>
          <configuration>
            <excludes><exclude>**/*HelpMojo.*</exclude></excludes>
          </configuration>
        </plugin>
        
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>${maven-site-plugin.version}</version>
        </plugin>
        
        <plugin>
          <groupId>org.eluder.coveralls</groupId>
          <artifactId>coveralls-maven-plugin</artifactId>
          <version>${coveralls-maven-plugin.version}</version>
          <configuration>
            <repoToken>${env.coveralls}</repoToken>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>
    
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>${maven-plugin-plugin.version}</version>
        <configuration>
          <goalPrefix>reproducible-build</goalPrefix>
          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
        </configuration>
        <executions>
          <execution>
            <id>mojo-descriptor</id>
            <goals>
              <goal>descriptor</goal>
            </goals>
          </execution>
          <execution>
            <id>help-goal</id>
            <goals>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven-checkstyle-plugin.version}</version>
        <configuration>
          <propertyExpansion>config_loc=${project.basedir}</propertyExpansion>
          <configLocation>checkstyle.xml</configLocation>
          <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
          <consoleOutput>true</consoleOutput>
          <failsOnError>true</failsOnError>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
        </configuration>
        <executions>
          <execution>
            <goals><goal>check</goal></goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <reporting>
    <plugins>

      <!-- Static code analysis report -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>${findbugs-maven-plugin.version}</version>
        <configuration>
          <effort>max</effort>
          <threshold>Default</threshold>
        </configuration>
      </plugin>

      <!-- Unit tests report -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>${maven-surefire-report-plugin.version}</version>
      </plugin>

      <!-- Integration tests report -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>${maven-invoker-plugin.version}</version>
      </plugin>

      <!-- Plugin documentation report -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>${maven-plugin-plugin.version}</version>
        <configuration>
          <requirements>
            <jdk>${project.build.java.target}</jdk>
          </requirements>
        </configuration>
      </plugin>

      <!-- Project info report -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>${maven-project-info-reports-plugin.version}</version>
      </plugin>

      <!-- Code coverage report -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-maven-plugin.version}</version>
        <configuration>
          <excludes><exclude>**/*HelpMojo.*</exclude></excludes>
        </configuration>
      </plugin>

    </plugins>
  </reporting>

  <profiles>

    <!-- Run the integration tests -->
    <profile>
      <id>run-its</id>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>${maven-invoker-plugin.version}</version>
            <configuration>
              <debug>true</debug>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <pomIncludes>
                <pomInclude>*/pom.xml</pomInclude>
              </pomIncludes>
              <postBuildHookScript>verify</postBuildHookScript>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <settingsFile>src/it/settings.xml</settingsFile>
              <goals>
                <goal>clean</goal>
                <goal>test-compile</goal>
              </goals>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>install</goal>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>jacoco-prepare-agent-unit-test</id>
                <goals><goal>prepare-agent</goal></goals>
                <configuration>
                  <destFile>${project.build.directory}/jacoco/jacoco-ut.exec</destFile>
                </configuration>
              </execution>
              <execution>
                <id>jacoco-prepare-agent-integration-test</id>
                <phase>pre-integration-test</phase>
                <goals><goal>prepare-agent</goal></goals>
                <configuration>
                  <destFile>${project.build.directory}/jacoco/jacoco-it.exec</destFile>
                  <propertyName>invoker.mavenOpts</propertyName>
                </configuration>
              </execution>
              <execution>
                <id>jacoco-merge</id>
                <phase>post-integration-test</phase>
                <goals><goal>merge</goal></goals>
                <configuration>
                  <fileSets>
                    <fileSet>
                      <directory>${project.build.directory}/jacoco</directory>
                      <includes><include>*.exec</include></includes>
                    </fileSet>
                  </fileSets>
                </configuration>
              </execution>
            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>
    
    <!-- Additional goals to release the plugin -->
    <profile> 
      <id>release</id>
      <build>
        <plugins>
          
          <!-- Generate source attachment -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${maven-source-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals><goal>jar-no-fork</goal></goals>
              </execution>
            </executions>
          </plugin>
          
          <!-- Generate javadoc attachment -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals><goal>jar</goal></goals>
              </execution>
            </executions>
          </plugin>
          
          <!-- Sign the artifacts -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals><goal>sign</goal></goals>
              </execution>
            </executions>
          </plugin>
          
        </plugins>
      </build>
    </profile>

  </profiles>
</project>
