<?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>com.sanctionco.jmail</groupId>
  <artifactId>jmail</artifactId>
  <version>1.5.0</version>
  <packaging>jar</packaging>

  <name>jmail</name>
  <description>A modern, fast, zero-dependency library for working with emails in Java</description>
  <url>https://github.com/RohanNagar/jmail</url>

  <scm>
    <url>https://github.com/RohanNagar/jmail</url>
    <connection>scm:git:git@github.com:RohanNagar/jmail.git</connection>
    <developerConnection>scm:git:git@github.com:RohanNagar/jmail.git</developerConnection>
    <tag>v1.5.0</tag>
  </scm>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/mit-license.php</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Rohan Nagar</name>
      <email>rohannagar11@gmail.com</email>
    </developer>
  </developers>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- We need to set the Java version to 9 for IntelliJ since we have a module-info.java file
         Source is actually re-compiled for Java 8, so we can only use Java 8 features -->
    <java.minimum.version>1.9</java.minimum.version>

    <!-- Plugin versions -->
    <checkstyle.version>10.9.2</checkstyle.version>
    <checkstyle-plugin.version>3.2.1</checkstyle-plugin.version>
    <compiler-plugin.version>3.11.0</compiler-plugin.version>
    <gpg-plugin.version>3.0.1</gpg-plugin.version>
    <jacoco.version>0.8.8</jacoco.version>
    <javadoc-plugin.version>3.5.0</javadoc-plugin.version>
    <nexus-plugin.version>1.6.13</nexus-plugin.version>
    <release-plugin.version>3.0.0</release-plugin.version>
    <source-plugin.version>3.2.1</source-plugin.version>
    <surefire.version>3.0.0</surefire.version>

    <!-- Test dependency versions -->
    <equalsverifier.version>3.14.1</equalsverifier.version>
    <junit.version>5.9.2</junit.version>
    <junit.platform.version>1.9.2</junit.platform.version>
    <mockneat.version>0.4.8</mockneat.version>
  </properties>

  <!-- Specify releases to Maven Central -->
  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <name>Nexus Release Repository</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <!-- Only GPG sign and attach sources/javadoc when releasing -->
  <profiles>
    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <!-- Sign artifacts when releasing -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${gpg-plugin.version}</version>
            <configuration>
              <gpgArguments>
                <!-- Required arguments for reading the gpg passphrase from Maven settings.xml -->
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Attach source files -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>${source-plugin.version}</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Attach javadoc files -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${javadoc-plugin.version}</version>
            <configuration>
              <source>${java.minimum.version}</source>
              <doclint>none</doclint>
              <quiet>true</quiet>
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- Deploy to Maven Central -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <includes>
                <include>module-info.java</include>
              </includes>
              <release>9</release>
            </configuration>
          </execution>
          <execution>
            <id>recompile-java8</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <excludes>
                <exclude>module-info.java</exclude>
              </excludes>
              <release>8</release>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <compilerArgument>-Xlint:all</compilerArgument>
          <showWarnings>true</showWarnings>
          <showDeprecation>true</showDeprecation>
          <source>${java.minimum.version}</source>
          <target>${java.minimum.version}</target>
        </configuration>
      </plugin>

      <!-- Easily perform releases -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>${release-plugin.version}</version>
        <configuration>
          <releaseProfiles>release-sign-artifacts</releaseProfiles>
          <tagNameFormat>v@{project.version}</tagNameFormat>
        </configuration>
      </plugin>

      <!-- Enforce code style -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${checkstyle-plugin.version}</version>
        <configuration>
          <sourceDirectories>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
          </sourceDirectories>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
        </configuration>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <configLocation>checkstyle.xml</configLocation>
              <violationSeverity>warning</violationSeverity>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- Generate code coverage -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Configure unit tests -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>commons-validator</groupId>
      <artifactId>commons-validator</artifactId>
      <version>1.7</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.bbottema</groupId>
      <artifactId>emailaddress-rfc2822</artifactId>
      <version>2.3.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>javax.mail</artifactId>
      <version>1.6.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>jakarta.mail</artifactId>
      <version>2.0.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.andreinc</groupId>
      <artifactId>mockneat</artifactId>
      <version>${mockneat.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>nl.jqno.equalsverifier</groupId>
      <artifactId>equalsverifier</artifactId>
      <version>${equalsverifier.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.24.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
