<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2024 gematik GmbH

    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.gematik.test</groupId>
    <artifactId>gem-testdata</artifactId>
    <version>1.0.9</version>
    <packaging>jar</packaging>
    <name>gematik-testdata</name>
    <description>Standardized test data as used within gematik</description>
    <url>https://github.com/gematik/PROJEKT or project github.io page (e.g.:
        https://gematik.github.io/ref-HealthCardAccess/)
    </url>

    <scm>
        <url>https://github.com/gematik/PROJECT</url>
        <connection>scm:git:git://github.com/gematik/PROJECT.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:gematik/PROJECT.git</developerConnection>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/gematik/PROJECT/issues</url>
    </issueManagement>

    <organization>
        <name>gematik GmbH</name>
        <url>https://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>

    <properties>
        <version.java>17</version.java>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
        <jsonschema2pojo.version>1.2.2</jsonschema2pojo.version>
        <junit-jupiter.version>5.10.3</junit-jupiter.version>
        <lombok.version>1.18.34</lombok.version>
        <maven-javdoc-plugin.version>3.10.0</maven-javdoc-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-surefire.version>3.5.0</maven-surefire.version>
        <mycila.license-maven-plugin.version>4.6</mycila.license-maven-plugin.version>
        <spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
        <spotless.google-java-format.version>1.19.2</spotless.google-java-format.version>
        <central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
        <tiger.version>4.0.6</tiger.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>de.gematik.test</groupId>
            <artifactId>tiger-rbel</artifactId>
            <version>${tiger.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.20.1</version>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>com.github.java-json-tools</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>2.2.14</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>uk.org.webcompere</groupId>
            <artifactId>system-stubs-jupiter</artifactId>
            <version>2.1.6</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/main/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>com.github.sylvainlaurent.maven</groupId>
                <artifactId>yaml-json-validator-maven-plugin</artifactId>
                <version>1.0.4</version>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>validate</goal>
                        </goals>
                        <configuration>
                            <validationSets>
                                <validationSet>
                                    <jsonSchema>src/main/resources/de/gematik/test/testdata/schemes/gematik-test-patients.json</jsonSchema>
                                    <includes>
                                        <include>src/main/resources/de/gematik/test/testdata/patient/*.yaml</include>
                                    </includes>
                                </validationSet>
                                <validationSet>
                                    <jsonSchema>src/main/resources/de/gematik/test/testdata/schemes/gematik-test-hcpis.json</jsonSchema>
                                    <includes>
                                        <include>src/main/resources/de/gematik/test/testdata/institution/*.yaml</include>
                                    </includes>
                                </validationSet>
                                <validationSet>
                                    <jsonSchema>src/main/resources/de/gematik/test/testdata/schemes/gematik-test-hcps.json</jsonSchema>
                                    <includes>
                                        <include>src/main/resources/de/gematik/test/testdata/hcp/*.yaml</include>
                                    </includes>
                                </validationSet>
                                <validationSet>
                                    <jsonSchema>src/main/resources/de/gematik/test/testdata/schemes/gematik-test-insurances.json</jsonSchema>
                                    <includes>
                                        <include>src/main/resources/de/gematik/test/testdata/insurance/*.yaml</include>
                                    </includes>
                                </validationSet>

                            </validationSets>
                            <!-- Duplicate keys detection is turned on by default. -->
                            <detectDuplicateKeys>true</detectDuplicateKeys>
                            <allowEmptyFiles>false</allowEmptyFiles>
                            <!-- Allow comments in json files is turned off by default -->
                            <allowJsonComments>false</allowJsonComments>
                            <!-- Trailing commas are not allwed by default -->
                            <allowTrailingComma>true</allowTrailingComma>
                            <skip>false</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>${jsonschema2pojo.version}</version>
                <configuration>
                    <sourceDirectory>${basedir}/src/main/resources/de/gematik/test/testdata/schemes</sourceDirectory>
                    <targetPackage>de.gematik.test.testdata.model</targetPackage>
                    <usePrimitives>true</usePrimitives>
                    <useCommonsLang3>true</useCommonsLang3>
                    <includeAdditionalProperties>false</includeAdditionalProperties>
                    <removeOldOutput>true</removeOldOutput>
                    <addCompileSourceRoot>true</addCompileSourceRoot>
                    <useTitleAsClassname>true</useTitleAsClassname>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${mycila.license-maven-plugin.version}</version>
                <configuration>
                    <licenseSets>
                        <licenseSet>
                            <header>doc/license.header.txt</header>
                            <includes>
                                <include>**/target/**</include>
                                <include>**/src/**</include>
                                <include>**/target/generated-*/**</include>
                            </includes>
                            <useDefaultExcludes>true</useDefaultExcludes>
                        </licenseSet>
                    </licenseSets>
                    <mapping>
                        <vue>XML_STYLE</vue>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <id>license headers for sources</id>
                        <goals><goal>format</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                    <execution>
                        <id>license headers for test sources</id>
                        <goals><goal>format</goal>
                        </goals>
                        <phase>generate-test-sources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless-maven-plugin.version}</version>
                <configuration>
                    <formats>
                        <format>
                            <includes>
                                <include>**/*.yml</include>
                                <include>**/*.yaml</include>
                            </includes>
                            <excludes>
                                <exclude>**/target/**/*</exclude>
                            </excludes>
                            <trimTrailingWhitespace/>
                            <endWithNewline/>
                            <indent>
                                <spaces>true</spaces>
                                <spacesPerTab>2</spacesPerTab>
                            </indent>
                        </format>
                    </formats>
                    <java>
                        <toggleOffOn/>
                        <googleJavaFormat>
                            <version>${spotless.google-java-format.version}</version>
                            <style>GOOGLE</style>
                            <reflowLongStrings>true</reflowLongStrings>
                        </googleJavaFormat>
                    </java>
                    <groovy>
                        <includes>
                            <include>**/*.Jenkinsfile</include>
                        </includes>
                        <importOrder/>
                    </groovy>
                    <markdown>
                        <includes>
                            <include>**/*.md</include>
                        </includes>
                        <excludes>
                            <exclude>**/target/**/*</exclude>
                        </excludes>
                    </markdown>
                    <yaml>
                        <includes>
                            <include>**/*.yml</include>
                            <include>**/*.yaml</include>
                        </includes>
                    </yaml>
                    <json>
                        <includes>
                            <include>**/*.json</include>
                        </includes>
                    </json>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>apply</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>


            <!-- plugins required by gematik -->
            <plugin>
                <artifactId>jacoco-maven-plugin</artifactId>
                <groupId>org.jacoco</groupId>
                <version>${jacoco-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco.exec
                            </destFile>
                            <propertyName>surefireJacocoAgent</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>pre-integration-test</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>
                                ${project.build.directory}/coverage-reports/jacoco-it.exec
                            </destFile>
                            <propertyName>failsafeJacocoAgent</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco.exec
                            </dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco
                            </outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <goals>
                            <goal>report-integration</goal>
                        </goals>
                        <configuration>
                            <dataFile>
                                ${project.build.directory}/coverage-reports/jacoco-it.exec
                            </dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-it
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>sonar-maven-plugin</artifactId>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <version>4.0.0.4121</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-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>${maven-javdoc-plugin.version}</version>
                <configuration>
                    <doclint>none</doclint>
                    <includes>
                        <include>src/main/java/**</include>
                        <include>target/generated-sources/jsonschema2pojo/**</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire.version}</version>
                <configuration>
                    <argLine>
                        ${surefireJacocoAgent}
                        --add-opens java.base/java.lang=ALL-UNNAMED
                        --add-opens java.base/java.io=ALL-UNNAMED
                        --add-opens java.base/java.util=ALL-UNNAMED
                        -Dfile.encoding=${project.build.sourceEncoding}
                    </argLine>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>org.sonar.java.jacoco.JUnitListener</value>
                        </property>
                    </properties>
                    <excludedGroups>${excludedTestGroups}</excludedGroups>
                    <excludes>
                        <exclude>**/integrationtest/Test*.java</exclude>
                    </excludes>
                    <skip>${skipSurefire}</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>external</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <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>
</project>
