<?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.github.magistvan</groupId>
        <artifactId>match-predicting-client</artifactId>
        <version>6.40</version>
    </parent>

    <artifactId>match-predicting-public-api-android</artifactId>
    <name>Match Predicting Public API Android</name>
    <description>Public API for the Match Predicting Application to be used for Android (Kotlin code)</description>

    <properties>
        <!-- Basic properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.code.style>official</kotlin.code.style>
        <kotlin.compiler.jvmTarget>25</kotlin.compiler.jvmTarget>

        <!-- Dependency versions -->
        <kotlin.version>2.4.0</kotlin.version>
        <retrofit.version>3.0.0</retrofit.version>
        <jackson.version>2.22</jackson.version>

        <!-- Plugin versions -->
        <dokka.maven.plugin.version>2.2.0</dokka.maven.plugin.version>
    </properties>

    <dependencies>
        <!-- Kotlin -->
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit</artifactId>
            <version>${retrofit.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Generating kotlin code for Android usage from swagger documentation -->
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <configuration>
                    <generatorName>kotlin</generatorName>
                    <configOptions>
                        <library>jvm-retrofit2</library>
                        <useCoroutines>true</useCoroutines>
                        <dateLibrary>java8-localdatetime</dateLibrary>
                        <serializationLibrary>jackson</serializationLibrary>
                    </configOptions>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${project.artifactId}</artifactId>
                    <artifactVersion>${project.version}</artifactVersion>
                    <packageName>io.github.magistvan.matchpredicting.pub.api</packageName>
                    <generateApiTests>false</generateApiTests>
                    <generateModelTests>false</generateModelTests>
                    <generateSupportingFiles>false</generateSupportingFiles>
                </configuration>
                <executions>
                    <execution>
                        <configuration>
                            <inputSpec>${swagger.docs.output}/swagger.json</inputSpec>
                            <output>${project.basedir}</output>
                            <skipValidateSpec>true</skipValidateSpec>
                        </configuration>
                        <id>Generate Android API</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.dokka</groupId>
                <artifactId>dokka-maven-plugin</artifactId>
                <version>${dokka.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>dokka</id>
                        <goals>
                            <goal>javadocJar</goal>
                        </goals>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>${dokka.maven.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>dokka</id>
                                <goals>
                                    <goal>javadocJar</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>