<?xml version="1.0" encoding="UTF-8"?>
<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">
  <parent>
    <groupId>org.optaplanner</groupId>
    <artifactId>optaplanner-build-parent</artifactId>
    <version>8.40.0.Final</version>
    <relativePath>../build/optaplanner-build-parent/pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>optaplanner-operator</artifactId>
  <name>[Experimental] OptaPlanner Operator</name>
  <description>
    OptaPlanner solves planning problems.
    This lightweight, embeddable planning engine implements powerful and scalable algorithms
    to optimize business resource scheduling and planning.

    This module contains an operator that enables running OptaPlanner workloads on Kubernetes.
  </description>
  <url>https://www.optaplanner.org</url>

  <properties>
    <java.module.name>org.optaplanner.operator</java.module.name>
    <!-- Quarkus Ecosystem CI (and other CI possibly too) updates the version.io.quarkus property. -->
    <version.io.quarkus.override>2.15.0.Final</version.io.quarkus.override>
  </properties>

  <!-- TODO: Remove when OptaPlanner no longer supports Quarkus 2.13 -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>${version.io.quarkus.override}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.quarkiverse.operatorsdk</groupId>
      <artifactId>quarkus-operator-sdk</artifactId>
      <exclusions>
        <exclusion> <!-- Clashes with the io.quarkus:quarkus-openshift. -->
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-container-image-jib</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Test dependencies. -->
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5-mockito</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-test-kubernetes-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/application.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>src/k8s</directory>
        <filtering>true</filtering>
        <includes>
          <include>crd-solver.yml</include>
          <include>optaplanner-operator.yml</include>
        </includes>
        <targetPath>${project.build.directory}/install</targetPath>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${version.io.quarkus.override}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
              <goal>generate-code</goal>
              <goal>generate-code-tests</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <!-- Undeclared transitive dependencies come from quarkus-operator-sdk; managing them individually
                 is impractical and might bring incompatibilities. -->
            <id>analyze-only</id>
            <configuration>
              <failOnWarning>false</failOnWarning>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <activation>
        <property>
          <name>native</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <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>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <properties>
        <quarkus.package.type>native</quarkus.package.type>
      </properties>
    </profile>

    <profile>
      <id>openshift</id> <!-- Optional for use in OpenShift. -->
      <activation>
        <property>
          <name>openshift</name>
        </property>
      </activation>
      <properties>
        <quarkus.profile>openshift</quarkus.profile>
      </properties>
      <dependencies>
        <dependency>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-openshift</artifactId>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <!-- The image build does not work on Windows GHA, thus it cannot be a part of the full profile. -->
      <id>image</id>
      <activation>
        <property>
          <name>operator.image.build</name>
        </property>
      </activation>
      <properties>
        <quarkus.profile>image</quarkus.profile>
      </properties>
      <dependencies>
        <dependency>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-container-image-jib</artifactId>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

</project>
