<?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.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.1</version>
  </parent>

  <groupId>com.theicenet</groupId>
  <artifactId>theicenet-cryptography</artifactId>
  <version>1.2.2</version>
  <packaging>pom</packaging>

  <properties>
    <java.version>11</java.version>
  </properties>

  <scm>
    <connection>scm:git:git@bitbucket.org:theicenet/theicenet-cryptography.git</connection>
    <developerConnection>scm:git:git@bitbucket.org:theicenet/theicenet-cryptography.git</developerConnection>
    <url>https://bitbucket.org/theicenet/theicenet-cryptography/src</url>
    <tag>theicenet-cryptography-1.2.2</tag>
  </scm>

  <name>${project.groupId}:${project.artifactId}</name>
  <description>
    TheIceNet Cryptography is a library which makes easy to develop cryptography-based,
    production-grade Spring Boot applications.
  </description>
  <url>https://github.com/theicenet/theicenet-cryptography</url>

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

  <developers>
    <developer>
      <name>Juan Jose Fidalgo Moran</name>
      <email>jjfidalgo@theicenet.com</email>
      <organization>TheIceNet</organization>
      <organizationUrl>https://github.com/theicenet</organizationUrl>
    </developer>
  </developers>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.12.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>integration-test</goal>
              </goals>
            </execution>
            <execution>
              <id>verify</id>
              <goals>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.6</version>
          <configuration>
            <includes>
              <include>**/theicenet/**</include>
            </includes>
          </configuration>
          <executions>
            <execution>
              <id>prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>prepare-agent-integration</id>
              <goals>
                <goal>prepare-agent-integration</goal>
              </goals>
            </execution>
            <execution>
              <id>report</id>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
            <execution>
              <id>report-integration</id>
              <goals>
                <goal>report-integration</goal>
              </goals>
            </execution>
            <execution>
              <id>merge-results</id>
              <phase>verify</phase>
              <goals>
                <goal>merge</goal>
              </goals>
              <configuration>
                <fileSets>
                  <fileSet>
                    <directory>${project.build.directory}</directory>
                    <includes>
                      <include>*.exec</include>
                    </includes>
                  </fileSet>
                </fileSets>
                <destFile>${project.build.directory}/jacoco-aggregate.exec</destFile>
              </configuration>
            </execution>
            <execution>
              <id>post-merge-report</id>
              <phase>verify</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/jacoco-aggregate.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate
                </outputDirectory>
              </configuration>
            </execution>
            <execution>
              <id>check</id>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/jacoco-aggregate.exec</dataFile>
                <rules>
                  <rule>
                    <element>BUNDLE</element>
                    <limits>
                      <limit>
                        <counter>INSTRUCTION</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>0.90</minimum>
                      </limit>
                      <limit>
                        <counter>BRANCH</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>0.90</minimum>
                      </limit>
                    </limits>
                  </rule>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <modules>
    <module>theicenet-cryptography-test-support</module>
    <module>theicenet-cryptography-module</module>
    <module>theicenet-cryptography-spring-boot-starter</module>
    <module>theicenet-cryptography-acceptance-tests</module>
  </modules>

  <profiles>
    <!-- Profile to be use when releasing to OSSRH - Sonatype Maven Central -->
    <!-- Before releasing please make sure that you have added the required server configuration
         with 'ossrh' credentials into the settings.xml

                 <settings>
                  <servers>
                    <server>
                      <id>ossrh</id>
                      <username>your-jira-id</username>
                      <password>your-jira-pwd</password>
                    </server>
                  </servers>
                </settings>
    -->
    <!-- To release to OSSRH staging use

         - Create/checkout the branch which is going to be use for the release. It can be any branch,
           even master, but usually merges into master are only allowed via pull request. For this
           reason, it's advisable to create a new branch (from master), run all maven-release-plugin
           commands on that branch, and, once the release is finished, then create a pull request
           to merge the branch used to release and the release commits into master.

         - Set release version, create tag, set next SNAPSHOT version and push to Bitbucket Git

                "mvn release:clean -Prelease"

                "mvn release:prepare -Prelease"

                Note: Since the Release Plugin performs a number of operations that change the
                project in Git, it may be wise to do a dry run before a big release or on a new
                project.
                This will ask all the same questions, run the same tests, and output a copy of how
                the POMs will look after transformation,

                          "mvn release:prepare -DdryRun=true -Prelease"

         - Deploy to OSSRH staging

                "mvn release:perform -Prelease"

         - If <autoReleaseAfterClose> is set to false it only releases to OSSRH staging
         - If <autoReleaseAfterClose> is set to true it releases to OSSRH staging and automatically
           to Maven Central Repository

       If release has been done to OSSRH staging, it can be manually inspected in the staging
       Nexus Repository Manager on,

                https://oss.sonatype.org/#stagingRepositories

       The version that is in OSSRH staging can be released or dropped from the browser on,

                https://oss.sonatype.org/#stagingRepositories

       Also, it can be triggered by command line a RELEASE of the staging repository later with

                "cd target/checkout"
                "mvn nexus-staging:release -Prelease"

       Or if you find something went wrong you can DROP the staging repository with

                "cd target/checkout"
                "mvn nexus-staging:drop -Prelease"

       After releasing to Maven Central check the artifacts are on,

                https://repo.maven.apache.org/maven2/com/theicenet


       Important Note: SNAPSHOT versions releases have been intentionally disabled in this POM.
       In order to enable to be able to release SNAPSHOT versions, the next configuration needs
       to be added to the 'release' profile in this POM

                <distributionManagement>
                  <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                  </snapshotRepository>
                </distributionManagement>

       More info,

                http://central.sonatype.org/pages/ossrh-guide.html
                https://central.sonatype.org/pages/apache-maven.html

       Troubleshooting,

                - To fix the issue on MacOS with error message
                  'gpg: signing failed: Inappropriate ioctl for device'

                  https://gist.github.com/repodevs/a18c7bb42b2ab293155aca889d447f1b
                  https://tutorials.technology/solved_errors/21-gpg-signing-failed-Inappropriate-ioctl-for-device.html
                  https://stackoverflow.com/questions/57591432/gpg-signing-failed-inappropriate-ioctl-for-device-on-macos-with-maven
    -->
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
              <autoVersionSubmodules>true</autoVersionSubmodules>
              <useReleaseProfile>false</useReleaseProfile>
              <releaseProfiles>release</releaseProfiles>
              <goals>deploy</goals>
              <scmCommentPrefix>[theicenet-cryptography-release][skip ci]-</scmCommentPrefix>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.8</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>false</autoReleaseAfterClose>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.2.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <phase>verify</phase>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.3.1</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <phase>verify</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <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-gpg-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
              <keyname>pipeline@theicenet.com</keyname>
              <passphrase>${env.THEICENET_PIPELINE_GPG_PRIVATE_KEY_PASSWORD}</passphrase>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>