<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.gematik.epa</groupId>
    <artifactId>lib-ihe-xds</artifactId>
    <packaging>jar</packaging>
    <version>3.1.0</version>
    <name>lib-ihe-xds</name>
    <description>A lib to create and process IHE requests from/to more descriptive Java records</description>
    <url>https://github.com/gematik/lib-ihe-xds</url>
    <properties>
        <!-- Project Settings -->
        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
        <java.version>21</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <generated.sources.path>${project.basedir}/src/main/generated-java</generated.sources.path>
        <!-- SonarQube Params -->
        <sonar.coverage.jacoco.xmlReportPaths>
            ${project.basedir}/target/site/jacoco-aggregate/jacoco.xml
        </sonar.coverage.jacoco.xmlReportPaths>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.language>java</sonar.language>
        <sonar.exclusions>${generated.sources.path}/*,${generated.sources.path}/**/*</sonar.exclusions>
        <!-- Dependencies -->
        <asm.version>9.10.1</asm.version>
        <jacoco.version>0.8.15</jacoco.version>
        <pmd-java.version>7.25.0</pmd-java.version>
        <junit.version>6.1.0</junit.version>
        <!-- Plugin Versions -->
        <compiler.plugin.version>3.15.0</compiler.plugin.version>
        <fmt.maven.plugin.version>2.29</fmt.maven.plugin.version>
        <pmd.plugin.version>3.28.0</pmd.plugin.version>
        <surefire.plugin.version>3.5.6</surefire.plugin.version>
        <enforcer.plugin.version>3.6.3</enforcer.plugin.version>
        <helper.plugin.version>3.6.1</helper.plugin.version>
        <source.plugin.version>3.4.0</source.plugin.version>
        <javadoc.plugin.version>3.12.0</javadoc.plugin.version>
        <cxf-xjc.version>4.2.0</cxf-xjc.version>
        <xml.bind.jaxb.version>2.3.1</xml.bind.jaxb.version>
        <jackson.version>2.22.0</jackson.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.10.0</central-publishing-maven-plugin.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf.xjc-utils</groupId>
            <artifactId>cxf-xjc-runtime</artifactId>
            <version>${cxf-xjc.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.22.0</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.46</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.15.0</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <!-- Maven Enforcer Plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${enforcer.plugin.version}</version>
                    <configuration>
                        <rules>
                            <reactorModuleConvergence/>
                            <requireJavaVersion>
                                <version>${java.version}</version>
                            </requireJavaVersion>
                            <requireSameVersions>
                                <plugins>
                                    <plugin>org.apache.maven.plugins:maven-surefire-plugin</plugin>
                                    <plugin>org.apache.maven.plugins:maven-failsafe-plugin</plugin>
                                    <plugin>org.apache.maven.plugins:maven-surefire-report-plugin
                                    </plugin>
                                </plugins>
                            </requireSameVersions>
                        </rules>
                        <fail>true</fail>
                    </configuration>
                </plugin>
                <!-- Autoformat classes -->
                <!-- Use latest maven compiler plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${compiler.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>default-compile</id>
                            <configuration>
                                <release>${maven.compiler.target}</release>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <fork>true</fork>
                        <meminitial>256</meminitial>
                        <maxmem>512</maxmem>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.ow2.asm</groupId>
                            <artifactId>asm</artifactId>
                            <version>${asm.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <!-- Execute PMD Static Analysis -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>${pmd.plugin.version}</version>
                    <executions>
                        <execution>
                            <id>perform-analyse</id>
                            <goals>
                                <goal>pmd</goal>
                            </goals>
                            <phase>validate</phase>
                            <configuration>
                                <excludes>**/module-info.java</excludes>
                                <inputEncoding>${project.build.sourceEncoding}</inputEncoding>
                                <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                                <linkXRef>false</linkXRef><!-- disable requirement of jxr plugin -->
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>net.sourceforge.pmd</groupId>
                            <artifactId>pmd-java</artifactId>
                            <version>${pmd-java.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>net.sourceforge.pmd</groupId>
                            <artifactId>pmd-core</artifactId>
                            <version>${pmd-java.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <!-- Create Code Coverage reports -->
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                    <configuration>
                        <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <!-- Configure Unit Tests -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.plugin.version}</version>
                    <configuration>
                        <argLine>@{argLine} -Dfile.encoding=UTF-8</argLine>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.JUnitListener</value>
                            </property>
                        </properties>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${helper.plugin.version}</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${generated.sources.path}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${enforcer.plugin.version}</version>
            </plugin>
            <!-- Autoformat classes -->
            <plugin>
                <groupId>com.spotify.fmt</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>${fmt.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler.plugin.version}</version>
            </plugin>
            <!-- Execute PMD Static Analysis -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${pmd.plugin.version}</version>
            </plugin>
            <!-- Configure Unit Tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.plugin.version}</version>
            </plugin>
            <!-- Create Code Coverage reports -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
            </plugin>
            <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</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${javadoc.plugin.version}</version>
                <configuration>
                    <quiet>true</quiet>
                    <doclint>none</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Automatically fulfill gematik OSPO guidelines
                https://wiki.gematik.de/x/Gh_QJQ (Lizenz-Management in OSPO-Projekten)
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>2.7.1</version>
                <configuration>
                    <!-- file header -->
                    <licenseName>apache_v2_0</licenseName>
                    <licenseResolver>classpath://copyright-header/apache-license</licenseResolver>
                    <inceptionYear>2023</inceptionYear>
                    <organizationName>gematik GmbH</organizationName>
                    <canUpdateCopyright>true</canUpdateCopyright>
                    <failOnMissingHeader>true</failOnMissingHeader>
                    <failOnNotUptodateHeader>true</failOnNotUptodateHeader>
                    <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>

                    <!-- license download -->
                    <licensesOutputDirectory>${project.basedir}/third-party-licenses</licensesOutputDirectory>
                    <licensesOutputFile>${project.basedir}/third-party-licenses/licenses.xml</licensesOutputFile>
                    <forceDownload>false</forceDownload>

                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </configuration>

                <dependencies>
                    <dependency>
                        <groupId>de.gematik</groupId>
                        <artifactId>ospo-resources</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                </dependencies>

                <executions>
                    <!-- Download der transitiven Lizenzen -->
                    <execution>
                        <id>download-licenses</id>
                        <goals>
                            <goal>download-licenses</goal>
                        </goals>
                        <phase>none</phase>
                    </execution>

                    <!-- Update der Source-Header -->
                    <execution>
                        <id>update-file-header</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                    </execution>

                    <!-- Check der Source-Header -->
                    <execution>
                        <id>check-file-header</id>
                        <goals>
                            <goal>check-file-header</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>generate_code</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-xjc-plugin</artifactId>
                        <version>${cxf-xjc.version}</version>
                        <configuration>
                            <additionalJvmArgs>-Djavax.xml.accessExternalDTD=file -Duser.language=en</additionalJvmArgs>
                            <extensions>
                                <extension>org.apache.cxf.xjcplugins:cxf-xjc-ts:${cxf-xjc.version}</extension>
                                <extension>org.jvnet.jaxb2_commons:jaxb2-fluent-api:3.0</extension>
                                <extension>org.jvnet.jaxb2_commons:jaxb2-basics:0.13.1</extension>
                                <extension>javax.xml.bind:jaxb-api:${xml.bind.jaxb.version}</extension>
                                <extension>com.sun.xml.bind:jaxb-impl:${xml.bind.jaxb.version}</extension>
                            </extensions>
                        </configuration>
                        <executions>
                            <execution>
                                <id>generate-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>xsdtojava</goal>
                                </goals>
                                <configuration>
                                    <sourceRoot>${generated.sources.path}</sourceRoot>
                                    <xsdOptions>
                                        <xsdOption>
                                            <xsd>${project.basedir}/src/main/resources/schemas/IHE/RMD.xsd</xsd>
                                            <extensionArgs>
                                                <extensionArg>-Xfluent-api</extensionArg>
                                                <extensionArg>-XsimpleEquals</extensionArg>
                                                <extensionArg>-XsimpleHashCode</extensionArg>
                                                <extensionArg>-Xts</extensionArg>
                                            </extensionArgs>
                                        </xsdOption>
                                    </xsdOptions>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>external</id>
            <build>
                <plugins>
                    <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>
                                <configuration>
                                    <!-- This is necessary for gpg to not try to use the pinentry programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <scm>
        <url>https://github.com/gematik/lib-ihe-xds</url>
        <connection>scm:git:git://github.com/gematik/lib-ihe-xds.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:gematik/lib-ihe-xds.git</developerConnection>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/gematik/lib-ihe-xds/issues</url>
    </issueManagement>

    <organization>
        <name>gematik GmbH</name>
        <url>http://www.gematik.de</url>
    </organization>

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

    <developers>
        <developer>
            <name>gematik</name>
            <email>software-development@gematik.de</email>
            <url>https://gematik.github.io/</url>
            <organization>gematik GmbH</organization>
            <organizationUrl>https://www.gematik.de/</organizationUrl>
        </developer>
    </developers>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>${releaseDeploymentRepository}</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>${snapshotDeploymentRepository}</url>
        </snapshotRepository>
    </distributionManagement>
</project>
