<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.github.evansiroky</groupId>
  <artifactId>maven-semantic-release-example</artifactId>
  <packaging>jar</packaging>
  <version>3.1.8</version>
  <name>maven-semantic-release-example</name>
  <description>Example project to auto-deploy maven projects</description>
  <url>https://github.com/evansiroky/maven-semantic-release-example</url>
  <properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
  </properties>
  <licenses>
    <license>
      <name>MIT</name>
      <url>https://opensource.org/licenses/MIT</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Evan Siroky</name>
      <email>evan.siroky@yahoo.com</email>
      <organization>Conveyal</organization>
      <organizationUrl>https://conveyal.com/</organizationUrl>
    </developer>
  </developers>
  <!-- Define where the source code for this project lives -->
  <scm>
    <connection>scm:git:https://github.com/evansiroky/maven-semantic-release-example.git</connection>
    <developerConnection>scm:git:https://github.com/evansiroky/maven-semantic-release-example.git</developerConnection>
    <url>https://github.com/evansiroky/maven-semantic-release-example</url>
  </scm>
  <repositories>
    <repository>
      <id>sonatype-oss</id>
      <name>Sonatype OSS</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </repository>
  </repositories>
  <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>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <!-- We sign in the verify phase, which means it will happen before install and deploy (the last two phases)
                 but not before earlier phases like test or package. -->
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
            <!-- If using gpg > 2.1 it is necessary for gpg to not try to use the pinentry programs
              however, it looks like Travis does not need this entry -->
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- Allow attaching Javadoc during releases -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.10.4</version>
        <configuration>
          <source>11</source>
          <detectJavaApiLink>false</detectJavaApiLink>
          <!-- Turn off Java 8 strict Javadoc checking -->
          <additionalparam>-Xdoclint:none</additionalparam>
          <tags>
            <tag>
              <name>notnull</name>
              <placement>a</placement>
              <head>Not null</head>
            </tag>
            <tag>
              <name>default</name>
              <placement>a</placement>
              <head>Default:</head>
            </tag>
          </tags>
        </configuration>
        <executions>
          <!-- Compress Javadoc into JAR and include that JAR when deploying. -->
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <!-- Include zipped source code in releases -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <!-- Automatically close and deploy from OSSRH -->
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.6.7</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>ossrh</serverId>
          <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          <!-- Release versions will be synced to Maven Central automatically. -->
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
        </configuration>
      </plugin>

      <plugin>
        <!-- This plugin is optional for projects deployed with maven-semantic-release
          This is mainly used to create a shaded jar with a specific version id.
          In the workflow at Conveyal, we deploy these generated jar files to s3.
          Note: this works in conjunction with the maven-shade-plugin -->
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>revision</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
          <gitDescribe>
            <tags>true</tags>
          </gitDescribe>
        </configuration>
      </plugin>

      <plugin>
        <!-- This plugin is optional for projects deployed with maven-semantic-release
          This is mainly used to create a shaded jar with a specific version id.
          In the workflow at Conveyal, we deploy these generated jar files to s3.
          Note: this works in conjunction with the git-commit-id-plugin -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.2</version>
        <!-- Create a version of the JAR that includes all dependencies.
             We don't want this to be attached and deployed, but we'll have Travis upload it to S3. -->
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <!-- Name the shaded JAR after the git describe string. This makes it uniquely identifiable so we can
                   run analysis workers with a specific commit or tag of R5. The shaded JAR is not "attached" to
                   deployments because this will cause it to be renamed to the standard timestamped name and sorted
                   into a Maven repo directory by version number. -->
              <finalName>${git.commit.id.describe}</finalName>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <manifestEntries>
                    <Main-Class>com.conveyal.r5.R5Main</Main-Class>
                    <!-- The ImageIO lines allow some image reader plugins to work see https://stackoverflow.com/questions/7051603/jai-vendorname-null#18495658 -->
                    <Specification-Title>Java Advanced Imaging Image I/O Tools</Specification-Title>
                    <Specification-Version>1.1</Specification-Version>
                    <Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
                    <Implementation-Title>com.sun.media.imageio</Implementation-Title>
                    <Implementation-Version>1.1</Implementation-Version>
                    <Implementation-Vendor>Sun Microsystems, Inc.</Implementation-Vendor>
                    <Extension-Name>com.sun.media.imageio</Extension-Name>
                  </manifestEntries>
                </transformer>
                <!-- files overwrite each other and geotools does not function without this.
                     http://docs.geotools.org/latest/userguide/faq.html#how-do-i-create-an-executable-jar-for-my-geotools-app -->
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
              </transformers>
              <!-- signature files from included jars cause problems: http://stackoverflow.com/questions/999489 -->
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- This plugin calculates code coverage and generates a report during the test phase in maven.
        It is optional in the workflow of deploying with maven-semantic-release.
       -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.6</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <!-- JUnit is a Java testing framework.
      It is optional in the workflow of deploying with maven-semantic-release. -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
