<?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>org.kiwiproject</groupId>
        <artifactId>kiwi-parent</artifactId>
        <version>3.0.40</version>
    </parent>

    <artifactId>changelog-generator</artifactId>
    <version>1.5.3</version>
    <packaging>jar</packaging>

    <name>Changelog Generator</name>
    <description>
        Generates GitHub change logs.
    </description>
    <url>https://github.com/kiwiproject/kiwiproject-changelog</url>
    <inceptionYear>2021</inceptionYear>

    <scm>
        <connection>scm:git:https://github.com/kiwiproject/kiwiproject-changelog.git</connection>
        <developerConnection>scm:git:git@github.com:kiwiproject/kiwiproject-changelog.git</developerConnection>
        <url>https://github.com/kiwiproject/kiwiproject-changelog</url>
        <tag>v1.5.3</tag>
    </scm>

    <properties>
        <!-- Versions for required dependencies -->
        <kiwi-libraries-bom.version>2.6.0</kiwi-libraries-bom.version>
        <kiwi-bom.version>3.3.0</kiwi-bom.version>
        <kotlin-logging-jvm.version>8.0.4</kotlin-logging-jvm.version>
        <picocli.version>4.7.7</picocli.version>

        <!-- Versions for test dependencies -->

        <!-- Nothing to see here yet...move along... -->

        <!-- Versions for plugins -->
        <dokka-maven-plugin.version>2.2.0</dokka-maven-plugin.version>
        <exec-maven-plugin.version>3.6.3</exec-maven-plugin.version>
        <kotlin-maven-plugin.version>2.4.0</kotlin-maven-plugin.version>
        <maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
        <maven-enforcer-plugin.version>3.6.3</maven-enforcer-plugin.version>
        <maven-failsafe-plugin.version>3.5.6</maven-failsafe-plugin.version>
        <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
        <maven-shade-plugin.version>3.6.2</maven-shade-plugin.version>

        <!-- Kotlin settings -->
        <kotlin.code.style>official</kotlin.code.style>
        <kotlin.compiler.jvmTarget>17</kotlin.compiler.jvmTarget>

        <!-- Sonar properties -->
        <sonar.projectKey>kiwiproject_kiwiproject-changelog</sonar.projectKey>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.kiwiproject</groupId>
                <artifactId>kiwi-libraries-bom</artifactId>
                <version>${kiwi-libraries-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.kiwiproject</groupId>
                <artifactId>kiwi-bom</artifactId>
                <version>${kiwi-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- Required dependencies -->

        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.kiwiproject</groupId>
            <artifactId>kiwi</artifactId>
        </dependency>

        <dependency>
            <groupId>io.github.oshai</groupId>
            <artifactId>kotlin-logging-jvm</artifactId>
            <version>${kotlin-logging-jvm.version}</version>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli</artifactId>
            <version>${picocli.version}</version>
        </dependency>

        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
        </dependency>

        <!-- Test dependencies -->

        <dependency>
            <groupId>org.kiwiproject</groupId>
            <artifactId>kiwi-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit5</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>mockwebserver</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>17</release>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven-failsafe-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <configuration>
                    <mainClass>MainKt</mainClass>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer-plugin.version}</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <dependencyConvergence />
                                <requireMavenVersion>
                                    <version>3.3.9</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <!--
            When generating releases, use Dokka to generate the Javadocs.
            Unlike the docs, this performs the plugin in the package phase
            to ensure it happens before GPG signing (which happens at verify).

            ref: https://kotlinlang.org/docs/dokka-introduction.html
        -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>${dokka-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadocJar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            Use this profile to build the shaded JAR.
            We intentionally do not deploy the (large) shaded JAR to Maven Central.
        -->
        <profile>
            <id>shaded-jar</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>${maven-shade-plugin.version}</version>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.kiwiproject.changelog.App</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
