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

<!--
  ~ Copyright (c) 2024 vitasystems 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
  ~
  ~   https://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>org.ehrbase.openehr</groupId>
    <artifactId>bom</artifactId>
    <version>2.24.0</version>
    <packaging>pom</packaging>

    <name>EHRbase</name>
    <description>EHRbase is a Free, Libre, Open Source openEHR Clinical Data Repository</description>
    <url>https://ehrbase.org</url>

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

    <scm>
        <connection>scm:git:git://github.com/ehrbase/ehrbase.git</connection>
        <developerConnection>scm:git:ssh://github.com:ehrbase/ehrbase.git</developerConnection>
        <url>https://github.com/ehrbase/ehrbase</url>
    </scm>

    <developers>
        <developer>
            <name>Stefan Spiska</name>
            <email>stefan.spiska@vitagroup.ag</email>
            <organization>vitasystems GmbH</organization>
            <organizationUrl>https://www.vitagroup.ag/</organizationUrl>
        </developer>
    </developers>

    <properties>
        <!--
        Needed for including the ehrbase maven project as module in an encapsulating maven project with this pom as the base parent.
        The root pom from the encapsulating project needs override this property with the version used for defining this pom as parent.
        -->
        <ehrbase.version>${project.version}</ehrbase.version>
        <ehrbase.openehr.sdk.version>2.27.0</ehrbase.openehr.sdk.version>
        <!-- archie version should be in sync with sdk -->
        <!-- XXX: maybe this bom should use the SDK bom as parent to inherit this property -->
        <archie.version>3.13.0</archie.version>
        <commons-io.version>2.18.0</commons-io.version>
        <commons-lang3.version>3.17.0</commons-lang3.version>
        <flyway.version>11.1.1</flyway.version>
        <javamelody.version>1.99.1</javamelody.version>
        <json-path.version>2.9.0</json-path.version>
        <junit.version>5.10.2</junit.version>

        <!-- jooq -->
        <slf4j.version>2.0.17</slf4j.version>
        <jooq.version>3.19.15</jooq.version>
        <postgresql.version>42.7.4</postgresql.version>

        <!-- spring -->
        <spring-boot.version>3.4.2</spring-boot.version>
        <springdoc-openapi.version>2.8.5</springdoc-openapi.version>

        <!-- not used ehrbase but needed for the version plugin -->
        <log4j.version>2.24.2</log4j.version>
        <pf4j-spring.version>0.9.0</pf4j-spring.version>
        <pf4j.version>3.12.1</pf4j.version>
        <commons-collections4.version>4.4</commons-collections4.version>

        <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
        <git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
        <java-jwt.version>3.19.4</java-jwt.version>
        <spring-tx-cache.version>1.0.5</spring-tx-cache.version>

        <!-- maven plugins -->
        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
        <maven-jar-plugin.version>3.4.1</maven-jar-plugin.version>
        <maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
        <maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>3.5.3</maven-failsafe-plugin.version>
        <maven-jacoco-plugin.version>0.8.13</maven-jacoco-plugin.version>
        <maven-spotless-maven-plugin.version>2.46.1</maven-spotless-maven-plugin.version>
        <palantir-format.version>2.74.0</palantir-format.version>
        <maven-central-publishing-plugin.version>0.8.0</maven-central-publishing-plugin.version>
        <maven-versions-maven-plugin.version>2.17.1</maven-versions-maven-plugin.version>
        <maven-dockerfile-maven-plugin.version>1.4.13</maven-dockerfile-maven-plugin.version>
        <maven-sonar.scanner.version>3.11.0.3922</maven-sonar.scanner.version>
        <docker-maven-plugin.version>0.45.1</docker-maven-plugin.version>

    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- SDK pulls in slf4j 1.7.x, but Spring needs 2.0.x -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-bom</artifactId>
                <version>${slf4j.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr.sdk</groupId>
                <artifactId>bom</artifactId>
                <version>${ehrbase.openehr.sdk.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr.sdk</groupId>
                <artifactId>validation</artifactId>
                <version>${ehrbase.openehr.sdk.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons-io.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${commons-lang3.version}</version>
            </dependency>

            <!-- modules -->
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>rm-db-format</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>service</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>rest-ehr-scape</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>rest-openehr</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>application</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>api</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>cli</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>configuration</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>jooq-pg</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>plugin</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>aql-engine</artifactId>
                <version>${ehrbase.version}</version>
            </dependency>
            <dependency>
                <groupId>org.ehrbase.openehr</groupId>
                <artifactId>aql-engine</artifactId>
                <classifier>tests</classifier>
                <type>test-jar</type>
                <scope>test</scope>
                <version>${ehrbase.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
                <version>${spring-boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-to-slf4j</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.pf4j</groupId>
                <artifactId>pf4j-spring</artifactId>
                <version>${pf4j-spring.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                    <exclusion>
                        <artifactId>slf4j-reload4j</artifactId>
                        <groupId>org.slf4j</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.pf4j</groupId>
                <artifactId>pf4j</artifactId>
                <version>${pf4j.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>${log4j.version}</version>
            </dependency>

            <dependency>
                <groupId>com.nedap.healthcare.archie</groupId>
                <artifactId>openehr-rm</artifactId>
                <version>${archie.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>${commons-collections4.version}</version>
            </dependency>

            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${springdoc-openapi.version}</version>
            </dependency>
            <dependency>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-core</artifactId>
                <version>${flyway.version}</version>
            </dependency>
            <dependency>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-database-postgresql</artifactId>
                <version>${flyway.version}</version>
            </dependency>
            <dependency>
                <groupId>javax.annotation</groupId>
                <artifactId>javax.annotation-api</artifactId>
                <version>${javax.annotation-api.version}</version>
            </dependency>
            <dependency>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>${git-commit-id-plugin.version}</version>
            </dependency>

            <dependency>
                <groupId>net.bull.javamelody</groupId>
                <artifactId>javamelody-spring-boot-starter</artifactId>
                <version>${javamelody.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jooq</groupId>
                <artifactId>jooq</artifactId>
                <version>${jooq.version}</version>
            </dependency>
            <dependency>
                <groupId>com.auth0</groupId>
                <artifactId>java-jwt</artifactId>
                <version>${java-jwt.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.3.9</version>
            </dependency>
            <dependency>
                <groupId>com.ethlo.cache</groupId>
                <artifactId>spring-tx-cache-decorator</artifactId>
                <version>${spring-tx-cache.version}</version>
            </dependency>

        </dependencies>

    </dependencyManagement>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <configuration>
                    <generateBackupPoms>false</generateBackupPoms>
                </configuration>
            </plugin>
            <!--
            Releases can be tested by adding a server entry to the settings.xml
                <server>
                  <id>central</id>
                  <username>invalid</username>
                  <password>invalid</password>
                </server>

            then use `mvn versions:set -DnewVersion=2.19.0[-SNAPSHOT]  -DprocessAllModules=true` to define the version and
            check using ` mvn -B deploy -P release -DskipTests` if the correct release or snapshot version it tried to upload
            -->
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                </configuration>
            </plugin>
        </plugins>


        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>${maven-spotless-maven-plugin.version}</version>
                    <configuration>
                        <java>
                            <toggleOffOn>
                                <off>@format:off</off>
                                <on>@format:on</on>
                            </toggleOffOn>
                            <palantirJavaFormat>
                                <version>${palantir-format.version}</version>
                            </palantirJavaFormat>
                            <licenseHeader>
                                <file>${maven.multiModuleProjectDirectory}/spotless-lic-header</file>
                            </licenseHeader>
                        </java>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${maven-dependency-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${maven-versions-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <compilerArgs>
                            <arg>-parameters</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version>${maven-central-publishing-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>com.spotify</groupId>
                    <artifactId>dockerfile-maven-plugin</artifactId>
                    <version>${maven-dockerfile-maven-plugin.version}</version>
                    <configuration>
                        <dockerConfigFile/>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <configuration>
                        <mainClass>org.ehrbase.application.EhrBase</mainClass>
                    </configuration>
                    <executions>
                        <execution>
                            <id>build-info</id>
                            <goals>
                                <goal>build-info</goal>
                            </goals>
                            <configuration>
                                <additionalProperties>
                                    <archie.version>${archie.version}</archie.version>
                                    <openEHR_SDK.version>${ehrbase.openehr.sdk.version}</openEHR_SDK.version>
                                </additionalProperties>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>${maven-sonar.scanner.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>release</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>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
        Profile is used to verify that no -SNAPSHOT dependencies are used.
        $ mvn -P no-snapshots enforcer:enforce
        -->
        <profile>
            <id>no-snapshots</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>3.5.0</version>
                        <configuration>
                            <rules>
                                <requireReleaseDeps>
                                    <message>No Snapshots Allowed!</message>
                                    <excludes>
                                        <exclude>org.ehrbase.openehr</exclude>
                                    </excludes>
                                </requireReleaseDeps>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                        <executions>
                            <execution>
                                <id>enforce-banned-dependencies</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

</project>
