<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.github.belgif.rest.problem</groupId>
    <artifactId>belgif-rest-problem-parent</artifactId>
    <version>0.18.0</version>
  </parent>

  <artifactId>belgif-rest-problem-quarkus</artifactId>
  <name>${project.groupId}:${project.artifactId}</name>
  <packaging>jar</packaging>

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

  <dependencies>
    <dependency>
      <groupId>io.github.belgif.rest.problem</groupId>
      <artifactId>belgif-rest-problem</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-jackson-common</artifactId>
    </dependency>
    <dependency>
      <groupId>jakarta.enterprise</groupId>
      <artifactId>jakarta.enterprise.cdi-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <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>
  </dependencies>

  <build>
    <plugins>
      <!-- Rather than adding a dependency on io.github.belgif.rest.problem:belgif-rest-problem-java-ee:jakarta,
       we need to unpack and embed a filtered subset of the classes directly into belgif-rest-problem-quarkus:
       * Quarkus does not support portable CDI extensions, only CDI 4.0 build compatible extensions
       * Quarkus does not support EJB
       * Using maven-dependency-plugin instead of maven-shade-plugin because the latter causes issues with Quarkus
       -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.github.belgif.rest.problem</groupId>
                  <artifactId>belgif-rest-problem-java-ee</artifactId>
                  <classifier>jakarta</classifier>
                  <version>${project.version}</version>
                  <outputDirectory>target/classes</outputDirectory>
                  <excludes>
                    META-INF/MANIFEST.MF,
                    META-INF/services/jakarta.enterprise.inject.spi.Extension,
                    META-INF/services/io.github.belgif.rest.problem.i18n.LocaleResolver,
                    io/github/belgif/rest/problem/ee/jaxrs/EJBExceptionMapper.class,
                    io/github/belgif/rest/problem/ee/jaxrs/ProblemConfigurator.class,
                    io/github/belgif/rest/problem/ee/registry/CdiProblemTypeRegistry.class,
                    io/github/belgif/rest/problem/ee/jaxrs/i18n/*
                  </excludes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-extension-maven-plugin</artifactId>
        <version>${version.quarkus}</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>extension-descriptor</goal>
            </goals>
            <configuration>
              <deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <annotationProcessorPaths>
            <path>
              <groupId>io.quarkus</groupId>
              <artifactId>quarkus-extension-processor</artifactId>
              <version>${version.quarkus}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>
