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

    <name>${project.groupId}:${project.artifactId}</name>
    <description>
        This is a parent POM for projects in the Kiwi Project.
    </description>
    <url>https://github.com/kiwiproject/kiwi-parent</url>
    <inceptionYear>2020</inceptionYear>

    <organization>
        <name>Kiwi Project</name>
        <url>https://github.com/kiwiproject</url>
    </organization>

    <developers>
        <developer>
            <name>Chris Rohr</name>
            <organization>Kiwi Project</organization>
            <organizationUrl>https://github.com/kiwiproject</organizationUrl>
            <url>https://github.com/chrisrohr</url>
        </developer>
        <developer>
            <name>Scott Leberknight</name>
            <organization>Kiwi Project</organization>
            <organizationUrl>https://github.com/kiwiproject</organizationUrl>
            <url>https://github.com/sleberknight</url>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/kiwiproject/kiwi-parent.git</connection>
        <developerConnection>scm:git:git@github.com:kiwiproject/kiwi-parent.git</developerConnection>
        <url>https://github.com/kiwiproject/kiwi-parent</url>
        <tag>v3.0.7</tag>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <!-- Collect arguments for use by release plugin -->
        <arguments />

        <!-- Versions for required dependencies -->
        <!-- Nothing to see here. Move along, move along... -->

        <!-- Versions for provided dependencies -->
        <lombok.version>1.18.30</lombok.version>

        <!-- Versions for optional dependencies -->
        <!-- Nothing to see here. Move along, move along... -->

        <!-- Versions for test dependencies -->
        <assertj.version>3.24.2</assertj.version>
        <awaitility.version>4.2.0</awaitility.version>
        <junit.jupiter.version>5.10.1</junit.jupiter.version>
        <junit-pioneer.version>2.2.0</junit-pioneer.version>
        <mockito.version>5.8.0</mockito.version>

        <!-- Versions for plugins -->
        <jacoco-maven-plugin.version>0.8.11</jacoco-maven-plugin.version>
        <jshell-maven-plugin.version>1.4</jshell-maven-plugin.version>
        <lombok-maven-plugin.version>1.18.20.0</lombok-maven-plugin.version>
        <maven-clean-plugin.version>3.3.2</maven-clean-plugin.version>
        <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
        <maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
        <maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version>
        <maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
        <maven-install-plugin.version>3.1.1</maven-install-plugin.version>
        <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
        <maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
        <maven-release-plugin.version>3.0.1</maven-release-plugin.version>
        <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
        <maven-site-plugin.version>3.12.1</maven-site-plugin.version>
        <maven-source-plugin.version>3.3.0</maven-source-plugin.version>
        <maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
        <sonar-maven-plugin.version>3.10.0.2594</sonar-maven-plugin.version>
        <versions-maven-plugin.version>2.16.2</versions-maven-plugin.version>

        <!-- Build properties -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <maven-compiler-plugin.java.release>17</maven-compiler-plugin.java.release>
        <maven-compiler-plugin.encoding>UTF-8</maven-compiler-plugin.encoding>

        <!-- These will be overridden in each repo using this parent -->
        <sonar.projectKey>kiwiproject_kiwi-parent</sonar.projectKey>

        <!-- TODO: Check if these will be inherited so we can remove them from other repos -->
        <sonar.organization>kiwiproject</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    </properties>

    <dependencyManagement>

        <dependencies>

            <!-- ensure all JUnit dependencies have correct version from the JUnit BOM -->
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.jupiter.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>

    </dependencyManagement>

    <dependencies>

        <!-- required dependencies -->

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

        <!-- provided dependencies -->

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- optional dependencies -->

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

        <!-- test dependencies -->

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitility.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit-pioneer</groupId>
            <artifactId>junit-pioneer</artifactId>
            <version>${junit-pioneer.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>

        <plugins>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>com.github.johnpoth</groupId>
                <artifactId>jshell-maven-plugin</artifactId>
                <version>${jshell-maven-plugin.version}</version>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>${maven-compiler-plugin.java.release}</release>
                    <encoding>${maven-compiler-plugin.encoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>${maven-deploy-plugin.version}</version>
            </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>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <mavenExecutorId>forked-path</mavenExecutorId>
                    <useReleaseProfile>false</useReleaseProfile>
                    <arguments>${arguments} -Prelease</arguments>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                </configuration>
            </plugin>

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

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

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

            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>${sonar-maven-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin.version}</version>
            </plugin>

        </plugins>

    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <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>

                    <!-- Delombok sources so that javadoc can be generated correctly -->
                    <plugin>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-maven-plugin</artifactId>
                        <version>${lombok-maven-plugin.version}</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${lombok.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>delombok</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>delombok</goal>
                                </goals>
                                <configuration>
                                    <addOutputDirectory>false</addOutputDirectory>
                                    <sourceDirectory>src/main/java</sourceDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- Make javadoc use the de-lomboked code -->
                            <sourcepath>target/generated-sources/delombok</sourcepath>

                            <!-- Make JavaDoc understand the "new" tags introduced in Java 8 (!) -->
                            <tags>
                                <tag>
                                    <name>apiNote</name>
                                    <placement>a</placement>
                                    <head>API Note:</head>
                                </tag>
                                <tag>
                                    <name>implSpec</name>
                                    <placement>a</placement>
                                    <head>Implementation Requirements:</head>
                                </tag>
                                <tag>
                                    <name>implNote</name>
                                    <placement>a</placement>
                                    <head>Implementation Note:</head>
                                </tag>
                            </tags>
                        </configuration>
                    </plugin>

                    <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.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus-staging-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
