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

    SPDX-FileCopyrightText: Copyright © 2021 Red Hat, Inc., and individual contributors as indicated by the @author tags.
    SPDX-License-Identifier: Apache-2.0

-->
<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.jboss</groupId>
    <artifactId>jboss-parent</artifactId>
    <version>55</version>
    <relativePath />
  </parent>

  <groupId>org.jboss.pnc.rex</groupId>
  <artifactId>parent</artifactId>
  <version>4.0.0</version>
  <packaging>pom</packaging>

  <name>Rex</name>
  <description>Clusterable scheduler of remotely executed tasks</description>
  <url>https://github.com/project-ncl/rex</url>
  <inceptionYear>2021</inceptionYear>

  <scm>
    <connection>scm:git:https://github.com/project-ncl/rex.git</connection>
    <developerConnection>scm:git:git@github.com:project-ncl/rex.git</developerConnection>
    <url>https://github.com/project-ncl/rex/</url>
    <tag>4.0.0</tag>
  </scm>

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

  <developers>
    <developer>
      <organization>RedHat</organization>
      <organizationUrl>https://www.redhat.com</organizationUrl>
    </developer>
  </developers>

  <modules>
    <module>core</module>
    <module>dto</module>
    <module>common</module>
    <module>model</module>
    <module>api</module>
    <module>rest-client</module>
  </modules>

  <properties>
    <quarkus.version>3.40.1.1</quarkus.version>
    <quarkus-openapi-generator.version>2.23.0</quarkus-openapi-generator.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.release>21</maven.compiler.release>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <jdk.min.version>21</jdk.min.version>
    <surefire-plugin.version>3.6.1</surefire-plugin.version>
    <lombok.version>1.18.48</lombok.version>
    <delombok-plugin.version>1.18.20.0</delombok-plugin.version>
    <delombok.output>${project.build.directory}/generated-sources/delombok</delombok.output>
    <slf4j.version>1.7.28</slf4j.version>
    <assertj.version>3.27.7</assertj.version>
    <restassured.version>4.1.1</restassured.version>
    <mapstruct.version>1.6.3</mapstruct.version>
    <pnc-api.version>4.0.0</pnc-api.version>

    <quarkus.jib.base-jvm-image>registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24@sha256:fa543e5a747c4d559144ef7ce7902ae6c4c8363a62cf4d7b776d174cf23a8b8d</quarkus.jib.base-jvm-image>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Modules -->
      <dependency>
        <groupId>org.jboss.pnc.rex</groupId>
        <artifactId>rex-common</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.pnc.rex</groupId>
        <artifactId>rex-core</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.pnc.rex</groupId>
        <artifactId>rex-dto</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.pnc.rex</groupId>
        <artifactId>rex-model</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.jboss.pnc.rex</groupId>
        <artifactId>rex-api</artifactId>
        <version>${project.version}</version>
      </dependency>

      <!-- Quarkus dependencies -->
      <dependency>
        <groupId>io.quarkus.platform</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>${quarkus.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>io.quarkiverse.openapi.generator</groupId>
        <artifactId>quarkus-openapi-generator</artifactId>
        <version>${quarkus-openapi-generator.version}</version>
      </dependency>

      <dependency>
        <groupId>io.quarkiverse.openapi.generator</groupId>
        <artifactId>quarkus-openapi-generator-oidc</artifactId>
        <version>${quarkus-openapi-generator.version}</version>
      </dependency>

      <!-- Regular dependencies -->
      <dependency>
        <groupId>org.jboss.pnc</groupId>
        <artifactId>pnc-api</artifactId>
        <version>${pnc-api.version}</version>
        <classifier>jakarta</classifier>
        <exclusions>
          <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
          </exclusion>
          <exclusion>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
          </exclusion>
          <exclusion>
            <groupId>javax.json.bind</groupId>
            <artifactId>javax.json.bind-api</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.jboss.pnc</groupId>
        <artifactId>quarkus-pnc-client-auth</artifactId>
        <version>4.0.0</version>
      </dependency>
      <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
        <version>${mapstruct.version}</version>
      </dependency>
      <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct-processor</artifactId>
        <version>${mapstruct.version}</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
      </dependency>

      <!-- Test dependencies -->
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>5.1.2</version>
          <configuration>
            <licenseSets>
              <licenseSet>
                <inlineHeader><![CDATA[SPDX-FileCopyrightText: Copyright © ${project.inceptionYear} Red Hat, Inc., and individual contributors as indicated by the @author tags.
SPDX-License-Identifier: Apache-2.0
]]></inlineHeader>
                <excludes>
                  <exclude>**/README.md</exclude>
                  <exclude>**/LICENSE</exclude>
                  <exclude>**/eclipse-codeStyle.xml</exclude>
                  <exclude>**/Dockerfile</exclude>
                  <exclude>**/scripts/**</exclude>
                  <exclude>**/images/**</exclude>
                  <exclude>**/.dockerignore</exclude>
                  <exclude>**/.mvn/**</exclude>
                  <exclude>**/.github/**</exclude>
                  <exclude>**/mvnw*</exclude>
                  <exclude>**/**.properties</exclude>
                  <exclude>**/infinispan-devservice-config.xml</exclude>
                  <exclude>**/application*.yaml</exclude>
                  <exclude>**/openapi.*</exclude>

                  <!-- Exclude downloaded/generated -->
                  <exclude>**/.cache/**</exclude>
                  <exclude>**/rest-config.json</exclude>
                  <exclude>**/Test*.html</exclude>

                  <!-- Exclude everything under ignore subforder -->
                  <exclude>**/ignore/**</exclude>
                </excludes>
              </licenseSet>
            </licenseSets>
          </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.transformer</groupId>
            <artifactId>transformer-maven-plugin</artifactId>
            <version>0.5.0</version>
            <extensions>true</extensions>
            <configuration>
                <rules>
                    <jakartaDefaults>true</jakartaDefaults>
                    <invert>true</invert>
                </rules>
                <classifier>javax</classifier>
            </configuration>
        </plugin>
        <plugin>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok-maven-plugin</artifactId>
          <version>${delombok-plugin.version}</version>
          <configuration>
            <sourceDirectory>src/main/java</sourceDirectory>
            <outputDirectory>${delombok.output}</outputDirectory>
            <addOutputDirectory>false</addOutputDirectory>
          </configuration>
          <executions>
            <execution>
              <phase>prepare-package</phase>
              <goals>
                <goal>delombok</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${lombok.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <sourcepath>${project.build.directory}/generated-sources/delombok;${project.build.directory}/generated-sources/open-api</sourcepath>
            <doclint>all,-missing</doclint>
          </configuration>
          <executions>
            <execution>
              <phase>package</phase>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-maven-plugin</artifactId>
          <version>${quarkus.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>generate-code</goal>
                <goal>generate-code-tests</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerArgs>
            <arg>
              -parameters
            </arg>
          </compilerArgs>
          <forceJavacCompilerUse>true</forceJavacCompilerUse>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
          <reportFormat>plain</reportFormat>
          <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
            <maven.home>${maven.home}</maven.home>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>check</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <name>Central Portal Snapshots</name>
      <id>central-portal-snapshots</id>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <profiles>
    <profile>
      <id>native</id>
      <properties>
        <quarkus.package.type>native</quarkus.package.type>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${surefire-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemPropertyVariables>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <maven.home>${maven.home}</maven.home>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>license-format</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>format</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>central-release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
