<?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/maven-v4_0_0.xsd">

  <!-- Model Information -->
  <modelVersion>4.0.0</modelVersion>

  <!-- Artifact Information  -->
  <groupId>xyz.block</groupId>
  <artifactId>java-kotlin-maven-example-parent</artifactId>
  <version>0.0.1-alpha-4</version>
  <packaging>pom</packaging>
  <name>Block Open Source Java Kotlin Maven Example</name>
  <url>https://opensource.block.xyz</url>
  <description>Build Aggregator and Parent for Example to bootstrap new Java Kotlin Maven Projects</description>
  <inceptionYear>2024</inceptionYear>

  <!-- SCM -->
  <scm>
    <connection>scm:git:git://github.com/block-open-source/example-java-kotlin-maven-multimodule.git</connection>
    <!-- This has to be HTTPS, not git://, for maven-release-plugin to do AUTH correctly -->
    <developerConnection>scm:git:https://github.com/block-open-source/example-java-kotlin-maven-multimodule.git</developerConnection>
    <url>https://github.com/block-open-source/example-java-kotlin-maven-multimodule</url>
    <tag>v0.0.1-alpha-4</tag>
  </scm>

  <!-- Developers -->
  <developers>
    <developer>
      <id>Block</id>
      <name>Block, Inc.</name>
      <email>ospo@block.xyz</email>
    </developer>
  </developers>

  <!-- Issues -->
  <issueManagement>
    <system>github</system>
    <url>https://github.com/block-open-source/example-java-kotlin-maven-multimodule/issues</url>
  </issueManagement>

  <!-- Licenses -->
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <!-- Aggregate Modules -->
  <modules>
    <module>api</module>
    <module>impl</module>
    <!-- <module>distribution</module> -->
  </modules>

  <!-- Properties -->
  <properties>
    <!-- Versioning for platform -->
    <version.java>21</version.java>
    <version.kotlin>1.9.22</version.kotlin>
    <kotlin.jvm.target>${version.java}</kotlin.jvm.target>
    <kotlin.compiler.incremental>true</kotlin.compiler.incremental>

    <!-- Project properties -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Defines the server config in .maven_settings.xml to use in maven-release-plugin -->
    <project.scm.id>github</project.scm.id>

    <!--
    This section is where we declare the versioning and scope for dependencies of
    the platform and projects building atop the platform.

    Submodules should not define their own dependency versions
    because these must all co-exist in the same ClassLoading environment, and
    therefore have to be aligned across submodules. Thus we declare the versioning
    requirements here at the platform level.

    The <dependencyManagement> section of this POM enforces the versions declared
    here as properties. Because this POM is a BOM POM, these versions may be imported
    by projects building atop the Web5 Platform (ie. tbDEX, consumers, etc).

    If a submodule needs to introduce a new dependency or upgrade, define that
    dependency and version here such that other submodules in the build may pick
    up the same version. This will guarantee that submodule test suites are running
    in the correct ClassLoading environment aligned with the Web5 platform.

    More on BOM POMs:
    https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms
    -->

    <!-- Versioning for Extensions and Plugins -->
    <version.io.github.martinvisser>0.0.6</version.io.github.martinvisser>

    <!-- Versioning for Dependencies -->
    <version.org.junit.jupiter>5.10.1</version.org.junit.jupiter>

    <!-- Versioning for Test Dependencies -->
    <version.org.assertj>3.25.2</version.org.assertj>

    <!--
    Versioning for transitive Dependencies
    These are overrides for deps brought in transitively; reasoning
    and approach is documented below in <dependencyManagement> section
    -->

  </properties>

  <!-- Dependency Management -->
  <dependencyManagement>

    <dependencies>
      <!-- Direct Dependency Management -->
      <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>${version.kotlin}</version>
      </dependency>

      <!-- Test Dependencies Management -->
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${version.org.assertj}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-test</artifactId>
        <version>${version.kotlin}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-test-junit5</artifactId>
        <version>${version.kotlin}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${version.org.junit.jupiter}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${version.org.junit.jupiter}</version>
        <scope>test</scope>
      </dependency>

      <!--
      Transitive Dependency Management

      In this section we address build issues including security vulnerabilities
      in transitive dependencies we don't explicitly declare above or in the submodules
      Versioning and scope declared here will override anything inherited through
      transitivity, so use with care. Also note: these are in place for a
      point in time. As we maintain this software, the manual forced resolution we do
      here may:

      1) No longer be necessary (if we have removed a dependency path leading to dep)
      2) Break an upgrade (if we upgrade a dependency and this forces a lower version
         of a transitive dependency it brings in)

      So we need to exercise care here, and, when upgrading our deps, check to see if
      these overrides of transitive dependency versions and scope aren't breaking things.

      When adding an entry here, please reference the issue which explains why we
      needed to do this; it will help future maintainers understand if the force
      is still valid, should be removed, or handled in another way.

      When in doubt, ask! :)
      -->

    </dependencies>
  </dependencyManagement>

  <!-- Dependencies common to all packages -->
  <dependencies>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit5</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>

    <extensions>
      <extension>
        <groupId>io.github.martinvisser</groupId>
        <artifactId>kover-maven-plugin</artifactId>
        <version>${version.io.github.martinvisser}</version>
      </extension>
    </extensions>

    <pluginManagement>
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
          <configuration>
            <source>${version.java}</source>
            <target>${version.java}</target>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
          <configuration>
            <includes>
              <include>**/Test*.java</include>
              <include>**/*Test.java</include>
              <include>**/*Tests.java</include>
              <include>**/*TestCase.java</include>
            </includes>
            <trimStackTrace>false</trimStackTrace>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
          <configuration>
            <archive>
              <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              </manifest>
            </archive>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
          <configuration>
            <deployAtEnd>true</deployAtEnd>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.simplify4u.plugins</groupId>
          <artifactId>sign-maven-plugin</artifactId>
          <version>1.1.0</version>
          <executions>
            <execution>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>3.0.1</version>
          <configuration>
            <autoVersionSubmodules>true</autoVersionSubmodules>
            <pushChanges>true</pushChanges>
            <tagNameFormat>v@{project.version}</tagNameFormat>
            <scmCommentPrefix>[Block Release Manager &#x1f680;]</scmCommentPrefix>
            <scmReleaseCommitComment>@{prefix} Setting version to: @{releaseLabel}</scmReleaseCommitComment>
            <scmDevelopmentCommitComment>@{prefix} Setting next development version after: @{releaseLabel}</scmDevelopmentCommitComment>
          </configuration>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
          <groupId>com.github.ozsie</groupId>
          <artifactId>detekt-maven-plugin</artifactId>
          <version>1.23.5</version>
          <executions>
            <execution>
              <phase>verify</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <config>config/detekt.yml</config>
              </configuration>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>io.gitlab.arturbosch.detekt</groupId>
              <artifactId>detekt-formatting</artifactId>
              <version>1.23.5</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>io.github.martinvisser</groupId>
          <artifactId>kover-maven-plugin</artifactId>
          <version>${version.io.github.martinvisser}</version>
          <configuration>
            <!-- Rules are optional, but if none are configured the plugin cannot verify the coverage -->
            <!-- So we set them to something very low as to not fail builds -->
            <rules>
              <rule>
                <minValue>10</minValue>
                <metric>LINE</metric>
                <aggregation>COVERED_PERCENTAGE</aggregation>
              </rule>
              <rule>
                <minValue>10</minValue>
                <metric>BRANCH</metric>
                <aggregation>COVERED_PERCENTAGE</aggregation>
              </rule>
            </rules>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <groupId>org.jetbrains.kotlin</groupId>
          <artifactId>kotlin-maven-plugin</artifactId>
          <version>${version.kotlin}</version>
          <configuration>
            <jvmTarget>${kotlin.jvm.target}</jvmTarget>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>io.github.martinvisser</groupId>
        <artifactId>kover-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.github.ozsie</groupId>
        <artifactId>detekt-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jetbrains.dokka</groupId>
        <artifactId>dokka-maven-plugin</artifactId>
        <version>1.9.20</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>javadocJar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>sign-artifacts</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.simplify4u.plugins</groupId>
            <artifactId>sign-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- https://central.sonatype.org/publish/publish-maven/#deployment -->
      <id>ossrh</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.13</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh-releases</serverId>
              <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <distributionManagement>
        <snapshotRepository>
          <id>ossrh-snapshots</id>
          <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <!-- Sonatype's OSSRH - replicates to Maven Central within 30min of publish -->
        <repository>
          <id>ossrh-releases</id>
          <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
      </distributionManagement>
    </profile>
  </profiles>

  <distributionManagement>
    <repository>
      <uniqueVersion>false</uniqueVersion>
      <id>block-oss-releases</id>
      <name>Block OSS Releases Repository</name>
      <url>https://blockxyz.jfrog.io/artifactory/block-oss-releases-maven2</url>
      <layout>default</layout>
    </repository>
    <snapshotRepository>
      <uniqueVersion>false</uniqueVersion>
      <id>block-oss-snapshots</id>
      <name>Block OSS Snapshots Repository</name>
      <url>https://blockxyz.jfrog.io/artifactory/block-oss-snapshots-maven2</url>
      <layout>default</layout>
    </snapshotRepository>
  </distributionManagement>

  <repositories>
    <repository>
      <id>block-oss-thirdparty</id>
      <name>block-oss-thirdparty</name>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <url>https://blockxyz.jfrog.io/artifactory/block-oss-thirdparty-maven2/</url>
    </repository>
    <repository>
      <id>block-oss-snapshots</id>
      <name>block-oss-snapshots</name>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <url>https://blockxyz.jfrog.io/artifactory/block-oss-snapshots-maven2</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>block-oss-thirdparty</id>
      <name>block-oss-thirdparty</name>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <url>https://blockxyz.jfrog.io/artifactory/block-oss-thirdparty-maven2/</url>
    </pluginRepository>
  </pluginRepositories>

</project>
