<?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.github.librepdf</groupId>
    <artifactId>openpdf-parent</artifactId>
    <version>1.3.40</version> <!-- artifact.version -->
    <packaging>pom</packaging>

    <!-- please run mvn tidy:pom once in a while -->
    <name>OpenPDF - Free and Open PDF</name>
    <description>Open and Free PDF library.</description>
    <url>https://github.com/LibrePDF/OpenPDF</url>
    <licenses>
        <license>
            <name>GNU Lesser General Public License (LGPL), Version 2.1</name>
            <url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>Mozilla Public License Version 2.0</name>
            <url>https://www.mozilla.org/en-US/MPL/2.0/</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>The OpenPDF Project</name>
            <organizationUrl>https://github.com/librepdf</organizationUrl>
        </developer>
    </developers>

    <modules>
        <module>openpdf</module>
        <module>pdf-swing</module>
        <module>pdf-toolbox</module>
        <module>openpdf-fonts-extra</module>
    </modules>

    <scm>
        <url>scm:git:https://github.com/LibrePDF/OpenPDF</url>
        <connection>scm:git:https://github.com/LibrePDF/OpenPDF</connection>
        <developerConnection>scm:git:https://github.com/LibrePDF/OpenPDF</developerConnection>
    </scm>
    <!-- Distribution config from http://central.sonatype.org/pages/apache-maven.html#distribution-management-and-authentication -->
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <java-module-name>com.github.librepdf.openpdf.parent</java-module-name>
        <java.version>11</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Maven Plugins versions -->
        <maven-bundle-plugin.version>5.1.9</maven-bundle-plugin.version>
        <maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
        <maven-clean-plugin.version>3.3.2</maven-clean-plugin.version>
        <maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
        <maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
        <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
        <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
        <maven-release-plugin.version>3.0.1</maven-release-plugin.version>
        <maven-repository-plugin.version>2.4</maven-repository-plugin.version>
        <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
        <maven.test.failure.ignore>false</maven.test.failure.ignore>
        <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
        <pitest-junit5-plugin.version>1.2.1</pitest-junit5-plugin.version>
        <pitmp-maven-plugin.version>1.3.7</pitmp-maven-plugin.version>

        <!-- dependencies -->
        <bouncycastle.version>1.77</bouncycastle.version>
        <commons-io.version>2.15.1</commons-io.version>
        <dom4j.version>2.1.4</dom4j.version>
        <fop.version>2.9</fop.version>
        <jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
        <jcommon.version>1.0.24</jcommon.version>
        <jfreechart.version>1.5.4</jfreechart.version>
        <pdf-renderer.version>1.0.5</pdf-renderer.version>

        <!-- test-dependencies -->
        <assertj.version>3.25.3</assertj.version>
        <hamcrest.version>2.2</hamcrest.version>
        <jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
        <junit.version>5.10.2</junit.version>
        <mockito4.version>4.11.0</mockito4.version>
        <mockito5.version>5.9.0</mockito5.version>

        <checkstyle.version>10.13.0</checkstyle.version>
        <maven-jxr-plugin.version>3.3.2</maven-jxr-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk18on</artifactId>
                <version>${bouncycastle.version}</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-jdk18on</artifactId>
                <version>${bouncycastle.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.xmlgraphics</groupId>
                <artifactId>fop</artifactId>
                <version>${fop.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jfree</groupId>
                <artifactId>jfreechart</artifactId>
                <version>${jfreechart.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jfree</groupId>
                <artifactId>jcommon</artifactId>
                <version>${jcommon.version}</version>
            </dependency>
            <dependency>
                <groupId>org.swinglabs</groupId>
                <artifactId>pdf-renderer</artifactId>
                <version>${pdf-renderer.version}</version>
            </dependency>
            <dependency>
                <groupId>org.dom4j</groupId>
                <artifactId>dom4j</artifactId>
                <version>${dom4j.version}</version>
            </dependency>
            <dependency>
                <groupId>jakarta.servlet</groupId>
                <artifactId>jakarta.servlet-api</artifactId>
                <version>${jakarta.servlet-api.version}</version>
            </dependency>
            <!-- Common test dependencies -->
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>${assertj.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-api</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>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest</artifactId>
                <version>${hamcrest.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                    <configuration>
                        <configLocation>checkstyle.xml</configLocation>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>${checkstyle.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Create sources for better debugging and context assist -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Create javadoc for help -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <source>8</source>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <!-- Disable doclint checks to build it under java 8 javadoc -->
                        <configuration>
                            <additionalJOptions>-Xdoclint:none</additionalJOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Clean also test results -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${maven-clean-plugin.version}</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>./out</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>./test</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>./target</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>.</directory>
                            <includes>
                                <include>*.rtf</include>
                                <include>*.pdf</include>
                                <include>*.html</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <!-- Set java to 9 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgs>
                        <arg>-Xlint:unchecked</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <configuration>
                    <!-- Use the Bnd generated MANIFEST.MF in the jar -->
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <manifestEntries>
                            <Automatic-Module-Name>${java-module-name}</Automatic-Module-Name>
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-repository-plugin</artifactId>
                <version>${maven-repository-plugin.version}</version>
            </plugin>
            <!-- GPG signing config -->
            <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>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>${nexus-staging-maven-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>false</autoReleaseAfterClose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven-bundle-plugin.version}</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <!-- bind the manifest.mf generation after the 'compile' phase -->
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- unpack bundle, so humans can see the manifest without unpacking the jar -->
                    <unpackBundle>true</unpackBundle>
                </configuration>
            </plugin>
            <plugin>
                <groupId>eu.stamp-project</groupId>
                <artifactId>pitmp-maven-plugin</artifactId>
                <version>${pitmp-maven-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-junit5-plugin</artifactId>
                        <version>${pitest-junit5-plugin.version}</version>
                    </dependency>
                    <!--Need this because dep is optional and pitest can't find classes-->
                    <dependency>
                        <groupId>org.bouncycastle</groupId>
                        <artifactId>bcprov-jdk18on</artifactId>
                        <version>${bouncycastle.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <avoidCallsTo>
                        <avoidCallsTo>java.util.logging</avoidCallsTo>
                        <avoidCallsTo>org.apache.log4j</avoidCallsTo>
                        <avoidCallsTo>org.slf4j</avoidCallsTo>
                        <avoidCallsTo>org.apache.commons.logging</avoidCallsTo>
                    </avoidCallsTo>
                    <historyInputFile>${project.build.directory}/pitest</historyInputFile>
                    <historyOutputFile>${project.build.directory}/pitest</historyOutputFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>checkstyle</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>${maven-jxr-plugin.version}</version>
            </plugin>
        </plugins>
    </reporting>

    <profiles>
        <profile>
            <id>jdk11-plus</id>
            <activation>
                <jdk>[11,)</jdk>
            </activation>
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>org.mockito</groupId>
                        <artifactId>mockito-core</artifactId>
                        <version>${mockito5.version}</version>
                    </dependency>
                </dependencies>
            </dependencyManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${maven.compiler.plugin.version}</version>
                        <configuration>
                            <release>11</release>
                        </configuration>
                        <executions>
                            <execution>
                                <id>compile-java-11</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <release>11</release>
                                    <compileSourceRoots>
                                        <compileSourceRoot>${project.basedir}/src/main/java</compileSourceRoot>
                                    </compileSourceRoots>
                                    <multiReleaseOutput>true</multiReleaseOutput>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
