<?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>

    <parent>
        <groupId>io.airlift</groupId>
        <artifactId>airlift</artifactId>
        <version>409</version>
    </parent>

    <artifactId>api</artifactId>
    <packaging>jar</packaging>
    <name>api</name>
    <description>Airlift - API building</description>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>

        <air.compiler.fail-warnings>false</air.compiler.fail-warnings>

        <!-- TODO move these to airbase -->
        <dep.commons-fileupload2.version>2.0.0-M5</dep.commons-fileupload2.version>
        <dep.apache.httpcore.version>4.4.16</dep.apache.httpcore.version>
        <dep.apache.httpmime.version>4.5.14</dep.apache.httpmime.version>
        <dep.swagger.version>2.1.38</dep.swagger.version>
        <dep.openapi-generator-maven-plugin.version>7.7.0</dep.openapi-generator-maven-plugin.version>
        <dep.jackson-databind-nullable.version>0.2.9</dep.jackson-databind-nullable.version>
    </properties>

    <!-- TODO move these to airbase -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.swagger.parser.v3</groupId>
                <artifactId>swagger-parser-core</artifactId>
                <version>${dep.swagger.version}</version>
            </dependency>

            <dependency>
                <groupId>io.swagger.parser.v3</groupId>
                <artifactId>swagger-parser-v3</artifactId>
                <version>${dep.swagger.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-fileupload2-core</artifactId>
                <version>${dep.commons-fileupload2.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-fileupload2-jakarta-servlet6</artifactId>
                <version>${dep.commons-fileupload2.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>${dep.apache.httpcore.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>${dep.apache.httpmime.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <dependency>
                <groupId>org.openapitools</groupId>
                <artifactId>jackson-databind-nullable</artifactId>
                <version>${dep.jackson-databind-nullable.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>http-client</artifactId>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jaxrs</artifactId>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>json</artifactId>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>log</artifactId>
        </dependency>

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

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

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

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <classifier>classes</classifier>
        </dependency>

        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-fileupload2-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-fileupload2-jakarta-servlet6</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>jakarta.activation</groupId>
                    <artifactId>jakarta.activation-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.glassfish.hk2.external</groupId>
                    <artifactId>aopalliance-repackaged</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>node</artifactId>
            <scope>runtime</scope>
        </dependency>

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

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>bootstrap</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>http-server</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.swagger.parser.v3</groupId>
            <artifactId>swagger-parser-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.swagger.parser.v3</groupId>
            <artifactId>swagger-parser-v3</artifactId>
            <scope>test</scope>
        </dependency>

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

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

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</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-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${dep.openapi-generator-maven-plugin.version}</version>
                <configuration>
                    <generatorName>java</generatorName>
                    <configOptions>
                        <sourceFolder>src/main/java</sourceFolder>
                        <useJakartaEe>true</useJakartaEe>
                    </configOptions>
                    <output>${project.build.directory}/generated-test-sources/annotations</output>
                    <generateApiDocumentation>false</generateApiDocumentation>
                    <generateApiTests>false</generateApiTests>
                    <generateModelDocumentation>false</generateModelDocumentation>
                    <generateModelTests>false</generateModelTests>
                    <apiPackage>io.sirlift.api.generated</apiPackage>
                    <modelPackage>io.sirlift.api.generated.models</modelPackage>
                    <invokerPackage>io.sirlift.api.generated.client</invokerPackage>
                    <library>native</library>
                </configuration>
                <executions>
                    <execution>
                        <id>complex-recursive-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-test-sources</phase>
                        <configuration>
                            <inputSpec>${project.basedir}/src/test/resources/openapi/complex-recursive.json</inputSpec>
                        </configuration>
                    </execution>
                    <execution>
                        <id>simple-recursive-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-test-sources</phase>
                        <configuration>
                            <inputSpec>${project.basedir}/src/test/resources/openapi/simple-recursive.json</inputSpec>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>io.sirlift.api.generated,io.sirlift.api.generated.client,io.sirlift.api.generated.models</excludePackageNames>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!--
        Error-prone can't deal with the generated OpenApi code and there isn't a good way to exclude it other than this:

        Don't generate code during error-prone compilation and exclude TestRecursive.java which references the generated code.
    -->
    <profiles>
        <profile>
            <id>errorprone-compiler</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.openapitools</groupId>
                        <artifactId>openapi-generator-maven-plugin</artifactId>
                        <version>${dep.openapi-generator-maven-plugin.version}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <!--suppress MavenModelInspection -->
                        <configuration combine.children="merge">
                            <excludes>
                                <exclude>**/TestRecursive.java</exclude>
                            </excludes>
                            <testExcludes>
                                <testExclude>**/TestRecursive.java</testExclude>
                            </testExcludes>
                            <incrementalExcludes>
                                <incrementalExclude>**/TestRecursive.java</incrementalExclude>
                            </incrementalExcludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
