<?xml version="1.0" encoding="UTF-8"?>

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.3</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <groupId>ai.platon.commons</groupId>
  <artifactId>distributed-lock</artifactId>
  <version>1.4.2</version>

  <packaging>pom</packaging>

  <name>Distributed Lock</name>
  <description>A Distributed Lock</description>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>http://www.opensource.org/licenses/mit-license.php</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Alen Turković</name>
      <email>alturkovic@gmail.com</email>
      <organizationUrl>https://github.com/alturkovic</organizationUrl>
    </developer>
    <developer>
      <name>Vincent Zhang</name>
      <email>ivincent.zhang@gmail.com</email>
      <organization>platon.ai</organization>
      <timezone>+8</timezone>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/platonai/distributed-lock.git</connection>
    <developerConnection>scm:git:ssh://github.com:platonai/distributed-lock.git</developerConnection>
    <url>https://github.com/platonai/distributed-lock</url>
  </scm>

  <repositories>
    <repository>
      <id>Central</id>
      <url>https://repo1.maven.org/maven2/</url>
    </repository>

    <repository>
      <id>sonatype-snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <modules>
    <module>distributed-lock-api</module>
    <module>distributed-lock-core</module>
    <module>distributed-lock-mongo</module>
    <module>distributed-lock-example</module>
  </modules>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>ai.platon.commons</groupId>
        <artifactId>distributed-lock-api</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>ai.platon.commons</groupId>
        <artifactId>distributed-lock-core</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>ai.platon.commons</groupId>
        <artifactId>distributed-lock-mongo</artifactId>
        <version>${project.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>${kotlin.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
      <version>${junit.version}</version>
    </dependency>
  </dependencies>

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

    <plugins>
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <version>${kotlin.version}</version>

        <executions>
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>

          <execution>
            <id>test-compile</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!--  java  -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <executions>
          <!--  Replacing default-compile as it is treated specially by maven  -->
          <execution>
            <id>default-compile</id>
            <phase>none</phase>
          </execution>
          <!--  Replacing default-testCompile as it is treated specially by maven  -->
          <execution>
            <id>default-testCompile</id>
            <phase>none</phase>
          </execution>
          <execution>
            <id>java-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>java-test-compile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
          <source>${javac.src.version}</source>
          <target>${javac.target.version}</target>
        </configuration>
      </plugin>
      <!-- Skip maven-deploy-plugin to use nexus-staging-maven-plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>platon-release</id>

      <build>
        <plugins>
          <plugin>
            <groupId>org.jetbrains.dokka</groupId>
            <artifactId>dokka-maven-plugin</artifactId>
            <version>${dokka.version}</version>
            <executions>
              <execution>
                <!-- generate javadoc.jar before package gpg plugin can generate asc for it -->
                <phase>prepare-package</phase>
                <goals>
                  <goal>javadocJar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <sourceDirectories>
                <dir>${project.basedir}/src/main/java</dir>
                <dir>${project.basedir}/src/main/kotlin</dir>
              </sourceDirectories>
            </configuration>
          </plugin>
          <!-- Override parent pom's javadoc settings, skip generating javadoc, use kdoc instead -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.0.1</version>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <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-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>
          <!-- Skip maven-deploy-plugin to use nexus-staging-maven-plugin -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
          <!-- We want to sign the artifact, the POM, and all attached artifacts -->
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.7</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>OS-WIN</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

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

    <javac.src.version>11</javac.src.version>
    <javac.target.version>11</javac.target.version>
    <kotlin.version>1.5.32</kotlin.version>
    <dokka.version>1.4.32</dokka.version>

    <junit.version>4.13.2</junit.version>
  </properties>
</project>
