<?xml version="1.0"?>
<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.sf.scuba</groupId>
  <artifactId>scuba-smartcards</artifactId>
  <version>0.1.0</version>

  <name>SCUBA</name>
  <description>Smart Card Utils for Better Access.</description>
  <url>https://scuba.sourceforge.net</url>

  <licenses>
    <license>
      <name>GNU Lesser General Public License v3.0 or later</name>
      <url>https://www.gnu.org/licenses/lgpl-3.0.html</url>
      <distribution>repo</distribution>
      <comments>SPDX-License-Identifier: LGPL-3.0-or-later</comments>
    </license>
  </licenses>

  <scm>
    <url>https://sourceforge.net/projects/scuba/</url>
    <connection>scm:svn:https://svn.code.sf.net/p/scuba/code</connection>
  </scm>

  <developers>
    <developer>
      <id>martijno</id>
      <name>Martijn Oostdijk</name>
    </developer>
  </developers>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jdk.version>7</jdk.version>
    <java.version>${jdk.version}</java.version>
    <maven.compiler.source>${jdk.version}</maven.compiler.source>
    <maven.compiler.target>${jdk.version}</maven.compiler.target>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Keeps the JUnit Platform artifacts that jazzer-junit pulls in aligned with junit-jupiter. -->
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.14.4</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- @FuzzTest: replays src/test/resources/**/*Inputs in a normal build, fuzzes with -Pfuzz. -->
    <dependency>
      <groupId>com.code-intelligence</groupId>
      <artifactId>jazzer-junit</artifactId>
      <version>0.30.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.5.0</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.5.0</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.15.0</version>
        <configuration>
          <source>7</source>
          <target>7</target>
          <!-- JUnit 5 and Jazzer need Java 8. -->
          <testSource>8</testSource>
          <testTarget>8</testTarget>
          <showWarnings>true</showWarnings>
          <showDeprecation>true</showDeprecation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.5</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <archive>
            <manifestEntries>
              <!-- Reserves a stable name for when this jar is used as a Java module. -->
              <Automatic-Module-Name>net.sf.scuba.smartcards</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>3.1.4</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>3.1.4</version>
      </plugin>

      <plugin>
        <groupId>org.sonatype.central</groupId>
        <artifactId>central-publishing-maven-plugin</artifactId>
        <version>0.11.0</version>
        <extensions>true</extensions>
        <configuration>
          <publishingServerId>central</publishingServerId>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <profiles>
    <!--
      Coverage guided fuzzing with Jazzer, one @FuzzTest per run, e.g.:
        mvn -Pfuzz test -Dtest=TLVFuzzTest#tlvStream
      Runs stop at the first finding, or after @FuzzTest(maxDuration). Set JAZZER_MAX_DURATION=2m to
      stop earlier and JAZZER_KEEP_GOING=100 to continue past findings. Don't kill a run: the input
      in progress is then saved as a (false) finding.
      Findings are written next to the seeds in src/test/resources/net/sf/scuba/fuzz/,
      so a normal build replays them as regression tests.
    -->
    <profile>
      <id>fuzz</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <environmentVariables>
                <JAZZER_FUZZ>1</JAZZER_FUZZ>
              </environmentVariables>
              <!-- A small heap, so allocations driven by length fields show up as OutOfMemoryError findings. -->
              <argLine>-Xmx512m</argLine>
              <failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <build>
        <plugins>

          <!-- Sources attachment -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.4.0</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Javadoc attachment -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.12.0</version>
            <configuration>
              <source>8</source>
              <author>false</author>
              <version>false</version>
              <detectJavaApiLink>false</detectJavaApiLink>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- GPG Signed Components -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.8</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>
  </profiles>

</project>

