<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2019, 2025 Oracle and/or its affiliates.

    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

        http://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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>io.helidon.microprofile</groupId>
        <artifactId>helidon-microprofile-project</artifactId>
        <version>4.2.0</version>
    </parent>
    <groupId>io.helidon.microprofile.openapi</groupId>
    <artifactId>helidon-microprofile-openapi</artifactId>

    <name>Helidon Microprofile OpenAPI</name>

    <description>
        Helidon Microprofile OpenAPI implementation
    </description>

    <packaging>jar</packaging>

    <properties>
        <spotbugs.exclude>etc/spotbugs/exclude.xml</spotbugs.exclude>
        <openapi-interfaces-dir>${project.build.directory}/extracted-sources/openapi-interfaces</openapi-interfaces-dir>
        <openapi-impls-dir>${project.build.directory}/extracted-sources/openapi-impls</openapi-impls-dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.helidon.openapi</groupId>
            <artifactId>helidon-openapi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.config</groupId>
            <artifactId>microprofile-config-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.openapi</groupId>
            <artifactId>microprofile-openapi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.server</groupId>
            <artifactId>helidon-microprofile-server</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.webserver</groupId>
            <artifactId>helidon-webserver-service-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.service-common</groupId>
            <artifactId>helidon-microprofile-service-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>smallrye-open-api-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.dataformat</groupId>
                    <artifactId>jackson-dataformat-yaml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>smallrye-open-api-jaxrs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye</groupId>
            <artifactId>jandex</artifactId>
        </dependency>
        <dependency>
            <groupId>io.helidon.common.features</groupId>
            <artifactId>helidon-common-features-api</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>jakarta.interceptor</groupId>
            <artifactId>jakarta.interceptor-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.helidon.microprofile.testing</groupId>
            <artifactId>helidon-microprofile-testing-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.helidon.common.testing</groupId>
            <artifactId>helidon-common-testing-junit5</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!--
                    Used for the BasicServerTest.
                -->
                <groupId>io.smallrye</groupId>
                <artifactId>jandex-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>make-test-index</id>
                        <goals>
                            <goal>jandex</goal>
                        </goals>
                        <phase>process-test-classes</phase>
                        <configuration>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}/test-classes</directory>
                                    <excludes>
                                        <exclude>**/other/*.class</exclude>
                                    </excludes>
                                </fileSet>
                            </fileSets>
                            <indexDir>${project.build.testOutputDirectory}/META-INF</indexDir>
                        </configuration>
                    </execution>
                    <execution>
                        <id>make-second-test-index</id>
                        <goals>
                            <goal>jandex</goal>
                        </goals>
                        <phase>process-test-classes</phase>
                        <configuration>
                            <indexName>other.idx</indexName>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}/test-classes</directory>
                                    <includes>
                                        <include>**/other/*.class</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                            <indexDir>${project.build.testOutputDirectory}/META-INF</indexDir>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>io.helidon.common.features</groupId>
                            <artifactId>helidon-common-features-processor</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                        <path>
                            <groupId>io.helidon.config.metadata</groupId>
                            <artifactId>helidon-config-metadata-codegen</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                        <path>
                            <groupId>io.helidon.codegen</groupId>
                            <artifactId>helidon-codegen-apt</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                        <path>
                            <groupId>io.helidon.builder</groupId>
                            <artifactId>helidon-builder-codegen</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                        <path>
                            <groupId>io.helidon.codegen</groupId>
                            <artifactId>helidon-codegen-helidon-copyright</artifactId>
                            <version>${helidon.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>io.helidon.common.features</groupId>
                        <artifactId>helidon-common-features-processor</artifactId>
                        <version>${helidon.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>io.helidon.config.metadata</groupId>
                        <artifactId>helidon-config-metadata-codegen</artifactId>
                        <version>${helidon.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>io.helidon.codegen</groupId>
                        <artifactId>helidon-codegen-apt</artifactId>
                        <version>${helidon.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>io.helidon.builder</groupId>
                        <artifactId>helidon-builder-codegen</artifactId>
                        <version>${helidon.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>io.helidon.codegen</groupId>
                        <artifactId>helidon-codegen-helidon-copyright</artifactId>
                        <version>${helidon.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-openapi-interfaces</id>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <classifier>sources</classifier>
                            <failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
                            <outputDirectory>${openapi-interfaces-dir}</outputDirectory>
                            <includeGroupIds>org.eclipse.microprofile.openapi</includeGroupIds>
                            <includeArtifactIds>microprofile-openapi-api</includeArtifactIds>
                            <includes>org/eclipse/microprofile/openapi/models/**/*.java</includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-openapi-impls</id>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <classifier>sources</classifier>
                            <failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
                            <outputDirectory>${openapi-impls-dir}</outputDirectory>
                            <includeGroupIds>io.smallrye</includeGroupIds>
                            <includeArtifactIds>smallrye-open-api-core</includeArtifactIds>
                            <includes>io/smallrye/openapi/api/models/**/*.java</includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.helidon.build-tools</groupId>
                <artifactId>snakeyaml-codegen-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-snakeyaml-parsing-helper</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <outputDirectory>${project.build.directory}/generated-sources/annotations</outputDirectory>
                            <outputClass>io.helidon.microprofile.openapi.SnakeYAMLParserHelper</outputClass>
                            <interfacesConfig>
                                <inputDirectory>${openapi-interfaces-dir}</inputDirectory>
                            </interfacesConfig>
                            <implementationsConfig>
                                <inputDirectory>${openapi-impls-dir}</inputDirectory>
                            </implementationsConfig>
                            <implementationPrefix>io.smallrye</implementationPrefix>
                            <interfacePrefix>org.eclipse.microprofile.openapi</interfacePrefix>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- Allows test client to set restricted headers Origin and Host -->
                    <systemPropertyVariables>
                        <sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
