<?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">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>camunda-engine-rest-core-jakarta</artifactId>
  <name>Camunda Platform - engine - REST Jakarta</name>
  <packaging>jar</packaging>

  <parent>
    <groupId>org.camunda.bpm</groupId>
    <artifactId>camunda-engine-rest-root</artifactId>
    <relativePath>../</relativePath>
    <version>7.21.0</version>
  </parent>

  <properties>
    <rest.http.port>38081</rest.http.port>
    <version.resteasy>6.2.3.Final</version.resteasy>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>jakarta.platform</groupId>
        <artifactId>jakarta.jakartaee-bom</artifactId>
        <version>${version.jakarta-ee-spec}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
      <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-bom</artifactId>
        <version>${version.resteasy}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-io</groupId>
          <artifactId>commons-io</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- override managed version from commons-fileupload -->
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
      <artifactId>jackson-jakarta-rs-json-provider</artifactId>
      <exclusions>
        <exclusion>
          <groupId>jakarta.activation</groupId>
          <artifactId>jakarta.activation-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>jakarta.xml.bind</groupId>
          <artifactId>jakarta.xml.bind-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>

    <!-- provided deps -->
    <dependency>
      <groupId>jakarta.servlet</groupId>
      <artifactId>jakarta.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.activation</groupId>
      <artifactId>jakarta.activation-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>org.springframework</groupId>
          <artifactId>spring-jcl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-logging</artifactId>
      <scope>provided</scope>
    </dependency>

    <!--
      needed for offline shrinkwrap (in particular CustomJacksonDateFormatTest),
      BOMs must be installed before this module is built
    -->
    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-bom</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-core-internal-dependencies</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>jakarta.platform</groupId>
      <artifactId>jakarta.jakartaee-bom</artifactId>
      <version>${version.jakarta-ee-spec}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <!-- test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.hamcrest</groupId>
          <artifactId>hamcrest-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-testing</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <!-- copy main sources & resources -->
          <execution>
            <id>copy-main-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-sources/jakarta</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/main/java</directory>
                  <filtering>false</filtering>
                  <excludes>
                    <exclude>**/EmptyBodyFilter.java</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-main-resources</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-resources/jakarta</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/main/resources</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
          <!-- copy test sources & resources -->
          <execution>
            <id>copy-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-test-sources/jakarta</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/test/java</directory>
                  <filtering>false</filtering>
                  <excludes>
                      <exclude>**/TomcatServerBootstrap.java</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-test-sources-resteasy</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-test-sources/jakarta-resteasy</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/test/java-resteasy</directory>
                  <filtering>false</filtering>
                  <excludes>
                    <exclude>**/ResteasyTomcatServerBootstrap.java</exclude>
                    <exclude>**/ResteasySpecifics.java</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-test-resources</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-test-resources/jakarta</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/test/resources</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-test-resources-resteasy</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/generated-test-resources/jakarta-resteasy</outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/../engine-rest/src/test/resources-resteasy</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.eclipse.transformer</groupId>
        <artifactId>transformer-maven-plugin</artifactId>
        <!-- sources & test-sources -->
        <executions>
          <execution>
            <id>transform-jakarta-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformDirectory>${project.build.directory}/generated-sources/jakarta</transformDirectory>
            </configuration>
          </execution>
          <execution>
            <id>transform-jakarta-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformDirectory>${project.build.directory}/generated-test-sources/jakarta</transformDirectory>
            </configuration>
          </execution>
          <!-- resteasy test-sources & test-resources -->
          <execution>
            <id>transform-jakarta-test-sources-resteasy</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformDirectory>${project.build.directory}/generated-test-sources/jakarta-resteasy</transformDirectory>
            </configuration>
          </execution>
          <execution>
            <id>transform-jakarta-test-resources-resteasy</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>transform</goal>
            </goals>
            <configuration>
              <transformDirectory>${project.build.directory}/generated-test-resources/jakarta-resteasy</transformDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-jakarta-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/jakarta</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-jakarta-resource</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-resources/jakarta</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>add-jakarta-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-test-sources/jakarta</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-jakarta-test-resource</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-test-resources/jakarta</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <!-- This id must match the -Prelease-profile id value or else sources will be "uploaded" twice, which causes Nexus to fail -->
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skipTests>true</skipTests>
          <systemPropertyVariables>
            <restEasyVersion>${version.resteasy}</restEasyVersion>
          </systemPropertyVariables>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-maven-plugin</artifactId>
        <version>${version.shrinkwrap.resolvers}</version>
        <executions>
          <execution>
            <goals>
              <goal>propagate-execution-context</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>resteasy</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>

      <properties>
        <version.netty>4.1.89.Final</version.netty>
        <version.undertow>2.3.0.Final</version.undertow>
      </properties>

      <dependencies>
        <dependency>
          <groupId>io.undertow</groupId>
          <artifactId>undertow-servlet</artifactId>
          <version>${version.undertow}</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-core</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-undertow</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-netty4</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
          <version>${version.netty}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>false</skipTests>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-jakarta-resteasy-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${basedir}/src/test/java-resteasy</source>
                    <source>${project.build.directory}/generated-test-sources/jakarta-resteasy</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-jakarta-resteasy-test-resource</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>add-test-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource><directory>${project.build.directory}/generated-test-resources/jakarta-resteasy</directory></resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>wildfly-compatibility</id>

      <properties>
        <version.netty>4.1.89.Final</version.netty>
        <version.undertow>2.3.0.Final</version.undertow>
        <!-- Test with Resteasy version used by Wildfly 27.0.0.Final -->
        <version.resteasy>6.2.1.Final</version.resteasy>
      </properties>

      <dependencies>
        <dependency>
          <groupId>io.undertow</groupId>
          <artifactId>undertow-servlet</artifactId>
          <version>${version.undertow}</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-core</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-undertow</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-netty4</artifactId>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
          <version>${version.netty}</version>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>false</skipTests>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-jakarta-resteasy-test-source</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${basedir}/src/test/java-resteasy</source>
                    <source>${project.build.directory}/generated-test-sources/jakarta-resteasy</source>
                  </sources>
                </configuration>
              </execution>
              <execution>
                <id>add-jakarta-resteasy-test-resource</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>add-test-resource</goal>
                </goals>
                <configuration>
                  <resources>
                    <resource><directory>${project.build.directory}/generated-test-resources/jakarta-resteasy</directory></resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>below-jdk17</id>
      <activation>
        <jdk>(,17)</jdk>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <testExcludes>
                <exclude>**/AuthenticationFilterPathMatchingTest.java</exclude>
              </testExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>jdk17-and-onwards</id>
      <activation>
        <jdk>[17,)</jdk>
      </activation>

      <properties>
        <version.spring.framework>${version.spring.framework6}</version.spring.framework>
      </properties>

      <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <version>${version.spring.framework}</version>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <groupId>org.springframework</groupId>
              <artifactId>spring-jcl</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

</project>