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

    <groupId>com.rws.lt.lc.public-api</groupId>
    <artifactId>lc-public-api-sdk</artifactId>
    <version>25.0.5</version>
    <packaging>jar</packaging>
    <name>LC Public API SDK</name>

    <description>Client implementation for Language Cloud Public API.</description>
    <url>https://languagecloud.sdl.com/lc/api-docs/</url>
    <developers>
        <developer>
            <name>API and Extensibility Team</name>
            <email>api.extensibility.team@rws.com</email>
            <url>https://github.com/RWS/language-cloud-public-api-samples</url>
        </developer>
    </developers>
    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <url>https://github.com/RWS/language-cloud-public-api-samples</url>
        <connection>scm:git:git@github.com:RWS/language-cloud-public-api-samples.git</connection>
        <developerConnection>scm:git:git@github.com:RWS/language-cloud-public-api-samples.git</developerConnection>
    </scm>

    <properties>
        <java.version>11</java.version>
        <maven.compiler.plugin.version>3.14.0</maven.compiler.plugin.version>
        <openapi.generator.maven.plugin.version>7.14.0</openapi.generator.maven.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <feign-version>13.6</feign-version>
        <slf4j.version>2.0.13</slf4j.version>
        <jackson-version>2.19.1</jackson-version>
        <jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
        <exec-maven-plugin.version>3.5.1</exec-maven-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
        <spotbugs-annotations.version>4.9.3</spotbugs-annotations.version>
        <httpclient5.version>5.5</httpclient5.version>
        <commons-lang3.version>3.18.0</commons-lang3.version>
        <javax-annotation-api.version>1.3.2</javax-annotation-api.version>
        <lombok.version>1.18.38</lombok.version>
        <junit5-version>5.13.2</junit5-version>
        <mockito-junit-jupiter.version>5.18.0</mockito-junit-jupiter.version>
        <skip.bash.exec>false</skip.bash.exec>
    </properties>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <!-- configuration tag necessary because https://github.com/spring-projects/spring-boot/issues/10029-->
                        <configuration>
                            <source>1.8</source>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>retrieve-api-doc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>bash</executable>
                            <arguments>
                                <argument>${basedir}/src/main/resources/scripts/get-openapi.sh</argument>
                            </arguments>
                            <skip>${skip.bash.exec}</skip>
                        </configuration>
                    </execution>
                    <!-- Used to start and stop prism-server -->
                    <execution>
                        <id>versionate-openapi-spec</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>bash</executable>
                            <arguments>
                                <argument>${basedir}/openApiVersionator.sh</argument>
                            </arguments>
                            <skip>${skip.bash.exec}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>start-prism-server</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>bash</executable>
                            <arguments>
                                <argument>${basedir}/prism.sh</argument>
                                <argument>up</argument>
                            </arguments>
                            <skip>${skip.bash.exec}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-prism-server</id>
                        <phase>test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>bash</executable>
                            <arguments>
                                <argument>${basedir}/prism.sh</argument>
                                <argument>halt</argument>
                            </arguments>
                            <skip>${skip.bash.exec}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <forceLegacyJavacApi>true</forceLegacyJavacApi>
                </configuration>
            </plugin>

            <!-- The OpenApi Generator and its configuration -->
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>${openapi.generator.maven.plugin.version}</version>
                <configuration>
                    <generatorName>java</generatorName>
                    <library>feign</library>
                    <configurationFile>${project.basedir}/src/main/resources/gen-config.yml</configurationFile>
                    <configOptions>
                        <sourceFolder>src/gen/java/main</sourceFolder>
                        <interfaceOnly>true</interfaceOnly>
                        <dateLibrary>joda</dateLibrary>
                        <implicitHeaders>true</implicitHeaders> <!-- to skip headers in method params -->

                    </configOptions>
                    <output>${project.build.directory}/generated-sources</output>
                    <templateDirectory>src/main/resources/java-templates</templateDirectory>
                    <modelPackage>com.rws.lt.lc.publicapi.sdk.model</modelPackage>
                    <apiPackage>com.rws.lt.lc.publicapi.sdk.api</apiPackage>
                    <invokerPackage>com.rws.lt.lc.publicapi.sdk.invoker</invokerPackage>
                    <generateApiTests>false</generateApiTests>
                    <generateModelTests>false</generateModelTests>
                    <skipValidateSpec>true</skipValidateSpec>
                    <globalProperties>
                        <skipFormModel>false
                        </skipFormModel> <!-- to include the json object in addition to file in the multipart requests -->
                    </globalProperties>
                </configuration>
                <executions>
                    <execution>
                        <id>main-spec</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/PublicAPI.oas3.yml</inputSpec>
                        </configuration>
                    </execution>
                    <execution>
                        <id>webhooks-spec</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/Webhooks.oas3.yml</inputSpec>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>*.yml</exclude>
                    <exclude>java-templates/**</exclude>
                    <exclude>scripts/get-openapi.sh</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

    <!-- Dependencies required by the generated client -->
    <dependencies>
        <!-- @Nullable annotation -->
        <dependency>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs-annotations</artifactId>
            <version>${spotbugs-annotations.version}</version>
        </dependency>

        <!-- HTTP client: Netflix Feign -->
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-core</artifactId>
            <version>${feign-version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-jackson</artifactId>
            <version>${feign-version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-slf4j</artifactId>
            <version>${feign-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-form</artifactId>
            <version>${feign-version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-okhttp</artifactId>
            <version>${feign-version}</version>
        </dependency>

        <!-- JSON processing: jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>org.openapitools</groupId>
            <artifactId>jackson-databind-nullable</artifactId>
            <version>${jackson-databind-nullable-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-joda</artifactId>
            <version>${jackson-version}</version>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit5-version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito-junit-jupiter.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- our dependencies -->
        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>${httpclient5.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>${javax-annotation-api.version}</version>
        </dependency>
    </dependencies>

</project>