<?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>fr.xelians</groupId>
    <artifactId>sipg</artifactId>
    <version>1.36</version>
    <packaging>jar</packaging>

    <organization>
        <name>Xelians / Mintika</name>
    </organization>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <!-- Project Information -->
    <name>sipg</name>
    <url>https://github.com/Xelians/sipg</url>
    <description>Sip Generator</description>

    <developers>
        <developer>
            <name>Emmanuel Deviller</name>
            <organization>Xelians</organization>
            <organizationUrl>https://www.xelians.fr/</organizationUrl>
            <roles>
                <role>Developper</role>
            </roles>
        </developer>
        <developer>
            <name>Baptiste Nichèle</name>
            <organization>Mintika</organization>
            <organizationUrl>https://www.mintika.fr/</organizationUrl>
            <roles>
                <role>Advisor</role>
            </roles>
        </developer>
    </developers>

    <!-- General Properties -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <scm>
        <connection>scm:git:https://github.com/Xelians/sipg.git</connection>
        <developerConnection>scm:git:https://github.com/Xelians/sipg.git</developerConnection>
        <url>scm:git:https://github.com/Xelians/sipg.git</url>
        <tag>HEAD</tag>
    </scm>

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub Packages</name>
            <url>https://maven.pkg.github.com/Xelians/sipg</url>
        </repository>
        <site>
            <id>site</id>
            <url>
                http://localhost/sites/${project.groupId}/${project.artifactId}/${project.version}
            </url>
        </site>
    </distributionManagement>

    <dependencies>
        <!--  Xml -->
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>4.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>4.0.5</version>
        </dependency>
        <!-- We need a non-official Xerces 12 to deal with XSD 1.1. Unfortunately the
        official Apache Xerces 12.1 is not released on maven central -->
        <dependency>
            <groupId>org.ibissource</groupId>
            <artifactId>ibis-xerces</artifactId>
            <version>2.12.2-xml-schema-1.1</version>
        </dependency>

        <!--  Rng -->
        <dependency>
            <groupId>org.relaxng</groupId>
            <artifactId>jing</artifactId>
            <version>20220510</version>
            <exclusions>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!--  Json -->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.17.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.17.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.17.2</version>
        </dependency>

        <!--  Utils -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.17.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.27.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.17.0</version>
        </dependency>

        <!--  Log -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.16</version>
        </dependency>

        <dependency>
            <groupId>uk.gov.nationalarchives</groupId>
            <artifactId>droid-core</artifactId>
            <version>6.8.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.jaxb</groupId>
                    <artifactId>jaxb-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j2-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>com.google.jimfs</groupId>
            <artifactId>jimfs</artifactId>
            <version>1.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.32</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>3.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
            <version>1.12.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.11.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.5.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-source</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Unit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.2</version>
            </plugin>

            <!-- Jacoco code coverage -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.11</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.12.0</version>
            </plugin>
        </plugins>
    </build>

    <!-- Use "mvn site" to activate reporting -->
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.5.0</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>summary</report>
                            <report>dependency-info</report>
                            <report>ci-management</report>
                            <report>dependency-management</report>
                            <report>dependencies</report>
                            <report>dependency-convergence</report>
                            <report>plugin-management</report>
                            <report>plugins</report>
                            <report>issue-management</report>
                            <report>licenses</report>
                            <report>scm</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
<!--
            <plugin>
                <groupId>org.owasp</groupId>
                <artifactId>dependency-check-maven</artifactId>
                <version>11.0.0</version>
            </plugin>
-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>3.23.0</version>
                <configuration>
                    <linkXRef>true</linkXRef>
                    <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
                    <minimumTokens>100</minimumTokens>
                    <targetJdk>1.8</targetJdk>
                    <excludes>
                        <exclude>fr/**/*.java</exclude>
                        <exclude>org/**/*.java</exclude>
                        <exclude>uk/**/*.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.11</version>
            </plugin>
        </plugins>
    </reporting>
    <repositories>
        <repository>
            <id>maven_central</id>
            <name>Maven Central</name>
            <url>https://repo.maven.apache.org/maven2/</url>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <!-- Use "mvn clean generate-sources -Pseda21" to generate jaxb classes -->
            <id>seda21</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb2.maven2</groupId>
                        <artifactId>maven-jaxb2-plugin</artifactId>
                        <version>0.15.3</version>
                        <executions>
                            <execution>
                                <configuration>
                                    <generateDirectory>src/main/java/</generateDirectory>
                                    <schemaDirectory>src/main/resources/seda-2.1/</schemaDirectory>
                                    <schemaIncludes>
                                        <include>seda-vitam-2.1-main.xsd</include>
                                    </schemaIncludes>
                                    <bindingDirectory>src/main/resources/seda-2.1/
                                    </bindingDirectory>
                                    <bindingIncludes>
                                        <include>binding.xjb</include>
                                    </bindingIncludes>
                                    <catalog>src/main/resources/seda-2.1/seda-vitam.cat</catalog>
                                    <args>
                                        <arg>-Xinheritance</arg>
                                        <arg>-Xannotate</arg>
                                    </args>
                                    <strict>false</strict>
                                    <plugins>
                                        <plugin>
                                            <groupId>org.jvnet.jaxb2_commons</groupId>
                                            <artifactId>jaxb2-basics-annotate</artifactId>
                                            <version>1.1.0</version>
                                        </plugin>
                                    </plugins>
                                </configuration>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.jvnet.jaxb2_commons</groupId>
                                <artifactId>jaxb2-basics</artifactId>
                                <version>1.11.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Use "mvn clean generate-sources -Pseda22" to generate jaxb classes -->
            <id>seda22</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jvnet.jaxb</groupId>
                        <artifactId>jaxb-maven-plugin</artifactId>
                        <version>4.0.8</version>
                        <executions>
                            <execution>
                                <configuration>
                                    <generateDirectory>src/main/java/</generateDirectory>
                                    <schemaDirectory>src/main/resources/seda-2.2/</schemaDirectory>
                                    <schemaIncludes>
                                        <include>seda-vitam-main.xsd</include>
                                    </schemaIncludes>
                                    <bindingDirectory>src/main/resources/seda-2.2/
                                    </bindingDirectory>
                                    <bindingIncludes>
                                        <include>binding.xjb</include>
                                    </bindingIncludes>
                                    <catalog>src/main/resources/seda-2.2/seda-vitam.cat</catalog>
                                    <extension>true</extension>
                                    <args>
                                        <arg>-Xinheritance</arg>
                                        <arg>-Xannotate</arg>
                                    </args>
                                    <strict>false</strict>
                                    <plugins>
                                        <plugin>
                                            <groupId>org.jvnet.jaxb</groupId>
                                            <artifactId>jaxb-plugin-annotate</artifactId>
                                            <version>4.0.8</version>
                                        </plugin>
                                    </plugins>
                                </configuration>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.jvnet.jaxb</groupId>
                                <artifactId>jaxb-plugins</artifactId>
                                <version>3.0.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Use "mvn verify -Pcentral" to add javadoc and signature -->
            <id>central</id>
            <build>
                <plugins>
                    <!-- Generate Javadoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.10.1</version>
                        <configuration>
                            <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                            <excludePackageNames>org.*:uk.*:fr.gouv.*</excludePackageNames>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Sign artefact -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.3</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <!-- Use "mvn verify -Pgithub" to package in one big jar -->
            <id>github</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>3.3.0</version>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <classpathPrefix>lib/</classpathPrefix>
                                </manifest>
                            </archive>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-assembly</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
