<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright Germany 2024 Governikus GmbH & Co. KG

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<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>de.governikus.opensaml.extension</groupId>
    <artifactId>opensaml-governikus-extension</artifactId>
    <version>1.2.0</version>

    <name>opensaml-governikus-extension</name>
    <description>This project is an OpenSAML extension that allows to provide a Security Provider for signature
        marshalling and unmarshalling.
    </description>
    <url>https://gitlab.opencode.de/governikus/opensaml-governikus-extension</url>

    <scm>
        <!-- When preparing a release, add -DscmConnection=scm:hg:... -->
        <connection>${scmConnection}</connection>
        <tag>opensaml-governikus-extension-1.2.0</tag>
        <url>https://gitlab.opencode.de/governikus/opensaml-governikus-extension</url>
    </scm>

    <!-- opensaml is not available in maven central -->
    <repositories>
        <repository>
            <id>Shibboleth</id>
            <name>Shibboleth Repository</name>
            <url>https://build.shibboleth.net/maven/releases/</url>
        </repository>
    </repositories>

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

    <developers>
        <developer>
            <name>Governikus</name>
            <email>autent@governikus.de</email>
            <organization>Governikus</organization>
            <url>https://www.governikus.de</url>
        </developer>
    </developers>

    <properties>
        <!-- Java version -->
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>

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

        <!-- Sonar/Reporting settings -->
        <sonar.java.source>${maven.compiler.source}</sonar.java.source>
        <sonar.junit.reportPaths>${project.build.directory}/surefire-reports</sonar.junit.reportPaths>

        <!-- the surefire ${argLine} property, use for ${jacoco.agent.argLine} property in the coverage profile  -->
        <argLineTestExec>-Xmx1024m</argLineTestExec>

        <!--suppress UnresolvedMavenProperty -->
        <formatter-path>${project.basedir}</formatter-path>

        <!-- Disable the JavaDoc DocLint feature that comes with Java8 and checks
        the JavaDoc for errors and fail if some are found. -->
        <doclint>none</doclint>

        <!-- dependency versions -->
        <version.bouncycastle>1.84</version.bouncycastle>
        <version.opensaml>5.2.3</version.opensaml>

        <!-- manage dependencies from OpenSAML -->
        <version.guava>33.6.0-jre</version.guava>
        <version.xmlsec>4.0.4</version.xmlsec>
        <version.commons-lang3>3.20.0</version.commons-lang3>

        <!-- logging -->
        <version.slf4j>2.0.18</version.slf4j>

        <!-- testing -->
        <version.junit>6.1.1</version.junit>

        <!-- plugin versions -->
        <version.build-helper-maven-plugin>3.6.1</version.build-helper-maven-plugin>
        <version.central-publishing-maven-plugin>0.11.0</version.central-publishing-maven-plugin>
        <version.jacoco-maven-plugin>0.8.15</version.jacoco-maven-plugin>
        <version.maven-deploy-plugin>3.1.4</version.maven-deploy-plugin>
        <version.maven-formatter-plugin>2.29.0</version.maven-formatter-plugin>
        <version.maven-gpg-plugin>3.2.8</version.maven-gpg-plugin>
        <version.maven-javadoc-plugin>3.12.0</version.maven-javadoc-plugin>
        <version.maven-jxr-plugin>3.6.0</version.maven-jxr-plugin>
        <version.maven-release-plugin>3.3.1</version.maven-release-plugin>
        <version.maven-source-plugin>3.4.0</version.maven-source-plugin>
        <version.maven-surefire-plugin>3.5.6</version.maven-surefire-plugin>
        <version.sonar-jacoco-listeners>5.14.0.18788</version.sonar-jacoco-listeners>


    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- open SAML -->

            <dependency>
                <groupId>org.opensaml</groupId>
                <artifactId>opensaml-parent</artifactId>
                <version>${version.opensaml}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.opensaml</groupId>
                <artifactId>opensaml-saml-impl</artifactId>
                <version>${version.opensaml}</version>
            </dependency>

            <!-- BC -->
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk18on</artifactId>
                <version>${version.bouncycastle}</version>
            </dependency>

            <!-- manage dependencies from OpenSAML -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${version.guava}</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-jdk18on</artifactId>
                <version>${version.bouncycastle}</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcutil-jdk18on</artifactId>
                <version>${version.bouncycastle}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.santuario</groupId>
                <artifactId>xmlsec</artifactId>
                <version>${version.xmlsec}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${version.commons-lang3}</version>
            </dependency>

            <!-- logging -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${version.slf4j}</version>
            </dependency>

            <!-- testing -->
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${version.junit}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>${version.slf4j}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- open SAML -->
        <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>opensaml-saml-impl</artifactId>
        </dependency>

        <!-- testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <!-- http://maven.apache.org/plugins/maven-deploy-plugin/ -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>${version.maven-deploy-plugin}</version>
                    <configuration>
                        <deployAtEnd>true</deployAtEnd>
                    </configuration>
                </plugin>
                <plugin>
                    <!-- http://maven.apache.org/maven-release/maven-release-plugin/ -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>${version.maven-release-plugin}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <!-- per our convention, all submodules must have the same version
                            as the parent -->
                        <autoVersionSubmodules>true</autoVersionSubmodules>

                        <!-- prepareAndPerformRelease can be used as profile activation condition -->
                        <arguments>-DprepareAndPerformRelease</arguments>

                        <!-- for hg and git -->
                        <remoteTagging>false</remoteTagging>
                        <pushChanges>false</pushChanges> <!-- no auto push, better rollback -->
                        <localCheckout>true</localCheckout> <!-- for git and hg -->
                        <waitBeforeTagging>2</waitBeforeTagging> <!-- for review-board -->
                    </configuration>
                </plugin>
                <plugin>
                    <!-- http://maven.apache.org/surefire/maven-surefire-plugin/ -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.maven-surefire-plugin}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <runOrder>hourly</runOrder>
                        <!-- alphabetical on even hours, reverse alphabetical on odd hours -->
                        <forkMode>once</forkMode>
                        <forkCount>1</forkCount>
                        <!-- problem with reuse forks an jacoco : https://jira.sonarsource.com/browse/SONARJAVA-728 -->
                        <reuseForks>true</reuseForks>
                        <argLine>${argLineTestExec}</argLine>
                        <skip>false</skip>
                        <failIfNoTests>false</failIfNoTests>
                        <excludes>
                            <exclude>**/TestSuite*.*</exclude>
                            <exclude>**/*TestSuite.*</exclude>
                            <exclude>**/IT*.*</exclude>
                            <exclude>**/*IT.*</exclude>
                            <exclude>**/*IntegrationTest.*</exclude>
                            <exclude>**/*SystemTest.*</exclude>
                            <exclude>**/*PerformanceTest.*</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <!-- http://maven.apache.org/surefire/maven-surefire-report-plugin/ -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>${version.maven-surefire-plugin}</version>
                </plugin>
                <plugin>
                    <!-- http://www.eclemma.org/jacoco/trunk/doc/maven.html -->
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${version.jacoco-maven-plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${version.build-helper-maven-plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${version.maven-source-plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${version.maven-javadoc-plugin}</version>
                </plugin>

                <plugin>
                    <!-- https://maven.apache.org/jxr/maven-jxr-plugin/ -->
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jxr-plugin</artifactId>
                    <version>${version.maven-jxr-plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${version.maven-gpg-plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version>${version.central-publishing-maven-plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>${version.maven-formatter-plugin}</version>
                <configuration>
                    <configFile>${formatter-path}/GOV-formatting.xml</configFile>
                    <lineEnding>LF</lineEnding>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>validate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- from http://www.aheritier.net/maven-failsafe-sonar-and-jacoco-are-in-a-boat/ -->
        <profile>
            <id>coverage</id>
            <activation>
                <!-- activate automatically when built on Jenkins build server -->
                <property>
                    <name>env.JENKINS_URL</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.sonarsource.java</groupId>
                    <artifactId>sonar-jacoco-listeners</artifactId>
                    <version>${version.sonar-jacoco-listeners}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <inherited>true</inherited>
                        <configuration>
                            <reportsDirectory>${sonar.junit.reportPaths}</reportsDirectory>
                            <properties>
                                <property>
                                    <name>listener</name>
                                    <value>org.sonar.java.jacoco.JUnitListener</value>
                                </property>
                            </properties>
                            <argLine>${argLineTestExec} ${jacoco.agent.argLine}</argLine>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <!-- exclude javassist classes (leads to runtime exception in coverage) -->
                                <!-- see http://docs.sonarqube.org/display/PLUG/JaCoCo+Plugin for
                                    more information -->
                                <exclude>*_javassist_*</exclude>
                                <exclude>org.springframework.*</exclude>
                            </excludes>
                        </configuration>
                        <executions>
                            <!-- Unit tests -->
                            <execution>
                                <id>pre-unit-test</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <phase>initialize</phase>
                                <configuration>
                                    <!-- JaCoCo runtime agent for surefire-plugin -->
                                    <propertyName>jacoco.agent.argLine</propertyName>
                                    <append>true</append>
                                </configuration>
                            </execution>
                            <execution>
                                <id>post-unit-test</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <phase>test</phase>
                                <configuration>
                                    <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>attachSourceAndJavaDoc</id>
            <activation>
                <!-- activate automatically when built on Jenkins build server -->
                <property>
                    <name>env.JENKINS_URL</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <!-- http://stackoverflow.com/questions/4251488/maven-release-plugin-fails-source-artifacts-getting-deployed-twice -->
                            <!-- This id must match the -Prelease-profile id value or else sources
								will be "uploaded" twice, which cause Nexus to fail -->
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>attach-sources-new</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <inherited>true</inherited>
                        <configuration>
                            <quiet>true</quiet>
                            <detectJavaApiLink>false</detectJavaApiLink>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jxr-plugin</artifactId>
                        <inherited>true</inherited>
                        <executions>
                            <execution>
                                <id>main-jxr-package</id>
                                <goals>
                                    <goal>jxr</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <javadocDir>${project.build.directory}/apidocs</javadocDir>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>SignAndDeploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                        </configuration>
                        <executions>
                            <execution>
                                <id>deploy-artifacts</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>publish</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
