<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  This file is subject to the terms and conditions defined in file 'License.txt',
  ~  which is part of this source code package.
  -->

<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.alwaysonmobile</groupId>
        <artifactId>hullo-root</artifactId>
        <version>2.5.0</version>
    </parent>

    <artifactId>hullo-java</artifactId>
    <version>1.0.0</version>

    <description>Always On Mobile - Hullo Java SDK</description>
    <url>https://github.com/Always-On-Mobile/hullo-java</url>
    <scm>
        <connection>scm:git:git@github.com:Always-On-Mobile/hullo-java.git</connection>
        <developerConnection>scm:git:git@github.com:Always-On-Mobile/hullo-java.git</developerConnection>
        <url>https://github.com/Always-On-Mobile/hullo-java</url>
    </scm>

    <licenses>
        <license>
            <name>Unlicense</name>
            <url>http://unlicense.org</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Always On Mobile Ltd</name>
            <email>dev@alwaysonmobile.io</email>
            <organization>alwaysonmobile.io</organization>
            <organizationUrl>https://alwaysonmobile.io</organizationUrl>
        </developer>
    </developers>


    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <httpclient-version>5.1.3</httpclient-version>
        <jackson-version>2.14.1</jackson-version>
        <jackson-databind-version>2.14.1</jackson-databind-version>
        <jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
        <jakarta-annotation-version>1.3.5</jakarta-annotation-version>
        <junit-version>4.13.2</junit-version>
    </properties>

    <build>
        <finalName>hullo-java-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <!-- RELEASE_VERSION -->
                <version>6.6.0</version>
                <!-- /RELEASE_VERSION -->
                <executions>
                    <execution>
                        <id>java-client</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.parent.basedir}/hullo-api.yaml</inputSpec>
                            <generatorName>java</generatorName>
                            <library>apache-httpclient</library>
                            <groupId>io.alwaysonmobile</groupId>
                            <artifactId>hullo-java</artifactId>
                            <artifactVersion>1.0.0</artifactVersion>
                            <packageName>io.alwaysonmobile.hullo.api.client</packageName>
                            <apiPackage>io.alwaysonmobile.hullo.api.client</apiPackage>
                            <modelPackage>io.alwaysonmobile.hullo.api.client</modelPackage>
                            <output>${project.build.directory}/generated-sources/openapi/java</output>
                            <templateDirectory>${project.basedir}/templates/Java</templateDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>javascript-client</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.parent.basedir}/hullo-api.yaml</inputSpec>
                            <generatorName>javascript</generatorName>
                            <output>${project.build.directory}/generated-sources/openapi/javascript</output>
                            <configOptions>
                                <projectName>@alwaysonmobile/hullojs</projectName>
                                <moduleName>hullojs</moduleName>
                                <projectVersion>1.0.0</projectVersion>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- attach test jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <finalName>hullo-java-${project.version}</finalName>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>add_sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add_test_sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/test/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.4.1</version>
                <configuration>
                    <doclint>none</doclint>
                    <source>1.8</source>
                    <finalName>hullo-java-${project.version}</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <finalName>hullo-java-${project.version}</finalName>
                </configuration>
                <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-antrun-plugin</artifactId>-->
<!--                <version>3.1.0</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>copy-pom</id>-->
<!--                        <phase>compile</phase>-->
<!--                        <goals>-->
<!--                            <goal>run</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <target name="copy pom file to target directory">-->
<!--                                <copy todir="${project.build.directory}">-->
<!--                                    <fileset dir="${project.build.directory}/generated-sources/openapi/java" includes="pom.xml">-->
<!--                                        <filename regex="pom.xml"/>-->
<!--                                    </fileset>-->
<!--                                    <mapper type="regexp" from="pom.xml" to="hullo-java-${project.version}.pom"/>-->
<!--                                </copy>-->
<!--                            </target>-->
<!--                        </configuration>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
        </plugins>
    </build>

    <dependencies>

        <!-- @Nullable annotation -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
        </dependency>


        <!-- HTTP client: apache client -->
        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>${httpclient-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-databind-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</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>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <version>${jakarta-annotation-version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit-version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>production</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.0.1</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>0.4.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                            <skipPublishing>false</skipPublishing>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>