<?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>435</version>
    </parent>

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

    <properties>
        <air.compiler.fail-warnings>false</air.compiler.fail-warnings>
        <!-- skip modernizer as generated code isn't modern enough -->
        <air.check.skip-modernizer>true</air.check.skip-modernizer>

        <dep.openapi-generator-maven-plugin.version>7.23.0</dep.openapi-generator-maven-plugin.version>
        <openapitools.jackson.version>2.22.0</openapitools.jackson.version>
        <openapitools.jackson-databind-nullable.version>0.2.10</openapitools.jackson-databind-nullable.version>
        <openapitools.jakarta-annotation.version>3.0.0</openapitools.jakarta-annotation.version>
    </properties>

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

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${openapitools.jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${openapitools.jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>${openapitools.jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <version>${openapitools.jakarta-annotation.version}</version>
        </dependency>

        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <version>${openapitools.jackson-databind-nullable.version}</version>
        </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>/</sourceFolder>
                        <useJakartaEe>true</useJakartaEe>
                    </configOptions>
                    <output>${project.build.directory}/openapi-test-client</output>
                    <generateApiDocumentation>false</generateApiDocumentation>
                    <generateApiTests>false</generateApiTests>
                    <generateModelDocumentation>false</generateModelDocumentation>
                    <generateModelTests>false</generateModelTests>
                    <apiPackage>io.airlift.api.generated</apiPackage>
                    <modelPackage>io.airlift.api.generated.models</modelPackage>
                    <invokerPackage>io.airlift.api.generated.client</invokerPackage>
                    <library>native</library>
                </configuration>
                <executions>
                    <execution>
                        <id>complex-recursive-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- Note: this references a file in the "api" module -->
                            <inputSpec>${project.parent.basedir}/api/src/test/resources/openapi/complex-recursive.json</inputSpec>
                        </configuration>
                    </execution>
                    <execution>
                        <id>simple-recursive-test</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- Note: this references a file in the "api" module -->
                            <inputSpec>${project.parent.basedir}/api/src/test/resources/openapi/simple-recursive.json</inputSpec>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>com.fasterxml.jackson.core:*</exclude>
                                    <exclude>com.fasterxml.jackson.datatype:*</exclude>
                                </excludes>
                            </artifactSet>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <relocations>
                                <relocation>
                                    <pattern>javax</pattern>
                                    <shadedPattern>shaded.javax</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>jakarta</pattern>
                                    <shadedPattern>shaded.jakarta</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org</pattern>
                                    <shadedPattern>shaded.org</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>errorprone-compiler</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <!-- Disable errorprone compiler as it can't handle the generated code -->
                        <configuration combine.self="override">
                            <annotationProcessorPaths combine.self="override" />
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
