<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Copyright (c) 2019  Stefan Spiska (Vitasystems GmbH) and Hannover Medical School
  ~  This file is part of Project EHRbase
  ~
  ~  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>

    <parent>
        <groupId>org.ehrbase.openehr.sdk</groupId>
        <artifactId>bom</artifactId>
        <version>2.8.0</version>
        <relativePath>./bom/pom.xml</relativePath>
    </parent>

    <groupId>org.ehrbase.openehr.sdk</groupId>
    <artifactId>sdk-parent</artifactId>
    <version>2.8.0</version>
    <packaging>pom</packaging>
    <name>openEHR SDK</name>


    <modules>
        <module>bom</module>
        <module>client</module>
        <module>generator</module>
        <module>generator-maven-plugin</module>
        <module>response-dto</module>
        <module>opt-1.4</module>
        <module>serialisation</module>
        <module>terminology</module>
        <module>test-data</module>
        <module>validation</module>
        <module>test-coverage</module>
        <module>web-template</module>
        <module>util</module>
        <module>aql</module>
        <module>serialisation_conformance_test</module>
        <module>example-generator</module>
        <module>generator-commons</module>
    </modules>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <!-- since we now have JDK17 in our pipeline, we make sure the correct lib versions are used -->
        <maven.compiler.release>17</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <web-template-tests.version>8f3381a37d</web-template-tests.version>

        <skipIntegrationTests>true</skipIntegrationTests>
        <include.tests>**/*Test.java</include.tests>
        <test.profile>unit</test.profile>
        <license-header.dir>./</license-header.dir>
    </properties>

    <profiles>
        <!-- RUN UNIT TESTS ONLY -->
        <profile>
            <id>fast</id>
            <properties>
                <include.tests>**/*Test.java</include.tests>
                <test.profile>unit</test.profile>
            </properties>
        </profile>
        <!-- RUN INTEGRATION TESTS ONLY -->
        <profile>
            <id>slow</id>
            <properties>
                <include.tests>**/*IT.java</include.tests>
                <test.profile>integration</test.profile>
            </properties>
        </profile>
        <!-- RUN ALL JAVA TESTS (UNIT & INTEGRATION) -->
        <profile>
            <id>full</id>
            <properties>
                <include.tests>**/*</include.tests>
                <test.profile>all</test.profile>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <additionalJOption>-Xdoclint:none</additionalJOption>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <configuration>
                    <rules>
                        <bannedDependencies>
                            <searchTransitive>true</searchTransitive>
                            <excludes>
                                <exclude>ch.qos.logback:logback-classic</exclude>
                                <exclude>org.springframework</exclude>
                                <exclude>org.slf4j</exclude>
                                <exclude>io.springfox</exclude>
                                <exclude>io.swagger</exclude>
                            </excludes>
                            <includes>
                                <include>org.springframework:*:*:jar:test</include>
                                <include>org.slf4j:slf4j-api</include>
                                <include>org.slf4j:slf4j-simple:*:jar</include>
                            </includes>
                        </bannedDependencies>
                        <requireMavenVersion>
                            <version>3.0</version>
                        </requireMavenVersion>
                    </rules>
                    <fail>true</fail>
                </configuration>
                <executions>
                    <execution>
                        <id>enforce-banned-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <!-- SET ARG LINE PROPERTY FOR SUREFIRE -->
                    <execution>
                        <id>agent for unit tests</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <!-- SET ARG LINE PROPERTY FOR FAILSAFE -->
                    <execution>
                        <id>agent for integration tests</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <propertyName>failsafeArgLine</propertyName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                    <!-- SETS THE VM ARGUMENT LINE USED WHEN UNIT TESTS ARE RUN. -->
                    <argLine>${surefireArgLine}</argLine>
                </configuration>
                <executions>
                    <execution>
                        <id>${test.profile} tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <skipTests>false</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skipITs>${skipIntegrationTests}</skipITs>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <!-- SETS THE VM ARGUMENT LINE USED WHEN INTEGRATION TESTS ARE RUN. -->
                            <argLine>${failsafeArgLine}</argLine>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    <stagingProgressTimeoutMinutes>30</stagingProgressTimeoutMinutes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <configuration>
                    <java>
                        <toggleOffOn>
                            <off>@format:off</off>
                            <on>@format:on</on>
                        </toggleOffOn>
                        <palantirJavaFormat>
                            <version>2.39.0</version>
                        </palantirJavaFormat>
                        <licenseHeader>
                            <file>${license-header.dir}/license-header</file>
                        </licenseHeader>
                    </java>
                </configuration>
            </plugin>
        </plugins>

    </build>
</project>
