<?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.7.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>
    <!-- antlr4 and archie versions should be sync with sdk antlr4 and archie versions  -->
    <archie.version>3.3.0</archie.version>
    <commons-io.version>2.16.1</commons-io.version>
    <commons-lang3.version>3.14.0</commons-lang3.version>
    <ehrbase.openehr.sdk.version>2.17.0</ehrbase.openehr.sdk.version>
    <flyway.version>8.5.13</flyway.version>
    <jackson-bom.version>2.17.2</jackson-bom.version>
    <javamelody.version>1.99.0</javamelody.version>
    <jooq.version>3.19.10</jooq.version>
    <json-path.version>2.9.0</json-path.version>
    <junit.version>5.10.2</junit.version>

    <!-- jooq -->
    <postgresql.version>42.7.3</postgresql.version>

    <!-- spring -->
    <spring-boot.version>3.2.5</spring-boot.version>
    <springdoc-openapi.version>2.6.0</springdoc-openapi.version>

    <!-- not used ehrbase but needed for the version plugin -->
    <log4j.version>2.23.1</log4j.version>
    <pf4j-spring.version>0.9.0</pf4j-spring.version>
    <pf4j.version>3.11.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>

    <!-- 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.7.1</maven-dependency-plugin.version>
    <maven-failsafe-plugin.version>3.3.0</maven-failsafe-plugin.version>
    <maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
    <maven-jacoco-plugin.version>0.8.12</maven-jacoco-plugin.version>
    <maven-spotless-maven-plugin.version>2.43.0</maven-spotless-maven-plugin.version>
    <maven-nexus-staging-plugin.version>1.7.0</maven-nexus-staging-plugin.version>
    <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
    <maven-versions-maven-plugin.version>2.17.0</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>

  </properties>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <repositories>
    <repository>
      <id>ossrh-snapshots</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.fasterxml.jackson</groupId>
        <artifactId>jackson-bom</artifactId>
        <version>${jackson-bom.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>bom</artifactId>
        <version>${ehrbase.openehr.sdk.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr.sdk</groupId>
        <artifactId>serialisation</artifactId>
        <version>${ehrbase.openehr.sdk.version}</version>
        <exclusions>
          <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
          </exclusion>
        </exclusions>
      </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>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>service</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>rest-ehr-scape</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>rest-openehr</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>application</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>api</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>cli</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>configuration</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>jooq-pg</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>plugin</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.ehrbase.openehr</groupId>
        <artifactId>aql-engine</artifactId>
        <version>${project.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>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>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
      </dependency>
      <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
      </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>

    </dependencies>

  </dependencyManagement>


  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <configuration>
          <generateBackupPoms>false</generateBackupPoms>
        </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>2.39.0</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.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.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${maven-nexus-staging-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>
            <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>
