<?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>3.0.6</version>
    <relativePath />
  </parent>

  <groupId>io.netfoundry</groupId>
  <artifactId>identity</artifactId>
  <name>identity</name>
  <version>1.6.0-SNAPSHOT</version>
  <description>Identity Service</description>
  <packaging>jar</packaging>

  <properties>
    <spring-cloud.version>2022.0.2</spring-cloud.version>
    <skip.dump>true</skip.dump>
    <jacoco.version>0.8.8</jacoco.version>
    <sonar.organization>netfoundry</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.coverage.exclusions>src/test/*,**/StandardAwsCognitoClient.*,**/**Configuration.*, **/Auth0ManagementApiService.*</sonar.coverage.exclusions>
    <springdoc-openapi.version>1.6.7</springdoc-openapi.version>
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    <application.version.number>${project.version}</application.version.number>
    <java.version>17</java.version>
    <maven.compiler.release>17</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>


  <dependencies>

    <!-- Spring Boot Dependencies -->
    <!--Open Api Documentation -->
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-csv</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.0.2</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.retry</groupId>
      <artifactId>spring-retry</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>


    <!-- Spring Cloud Dependencies -->

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter</artifactId>
    </dependency>

    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-tracing-bridge-brave</artifactId>
    </dependency>


    <!-- NetFoundry Dependencies -->

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>common-util-framework</artifactId>
      <version>2.0.7</version>
    </dependency>
    <dependency>
        <!-- Caching -->
        <groupId>com.github.ben-manes.caffeine</groupId>
        <artifactId>caffeine</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>authorization</artifactId>
      <version>2.0.1</version>
      <classifier>client</classifier>
      <exclusions>
        <!-- Excluding default (4.0) version of httpclient in favor of the newer one (5.0) below -->
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>messaging-framework</artifactId>
      <version>0.5.3</version>
    </dependency>


    <!-- Amazon SDKs -->

    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>cognitoidentityprovider</artifactId>
    </dependency>

    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
    </dependency>


    <!-- Database Dependencies -->

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.32</version>
    </dependency>

    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-core</artifactId>
      <version>8.5.13</version>
    </dependency>

    <dependency>
      <groupId>org.flywaydb</groupId>
      <artifactId>flyway-mysql</artifactId>
      <version>8.5.13</version>
    </dependency>

    <!-- Misc. Minor Dependencies -->

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>net.logstash.logback</groupId>
      <artifactId>logstash-logback-encoder</artifactId>
      <version>7.3</version>
    </dependency>

    <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>mailapi</artifactId>
      <version>1.4.3</version>
    </dependency>

    <dependency>
      <groupId>org.simplejavamail</groupId>
      <artifactId>simple-java-mail</artifactId>
      <version>8.0.0</version>
    </dependency>

    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.9.4</version>
    </dependency>

    <dependency>
      <!-- semantic version parsing and comparison -->
      <groupId>com.vdurmont</groupId>
      <artifactId>semver4j</artifactId>
      <version>3.1.0</version>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents.client5</groupId>
      <artifactId>httpclient5</artifactId>
    </dependency>

    <!-- Testing Dependencies -->

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.icegreen</groupId>
      <artifactId>greenmail-spring</artifactId>
      <version>1.6.8</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>test</scope>
      <version>2.1.210</version>
    </dependency>

    <dependency>
      <groupId>io.findify</groupId>
      <artifactId>s3mock_2.13</artifactId>
      <version>0.2.6</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>

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

    <!-- Documentation Dependencies -->

    <dependency>
      <groupId>org.springframework.restdocs</groupId>
      <artifactId>spring-restdocs-mockmvc</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>capital.scalable</groupId>
      <artifactId>spring-auto-restdocs-core</artifactId>
      <version>2.0.5</version>
      <scope>test</scope>
    </dependency>


    <!-- Internal NF dependencies -->

    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>


  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>${spring-cloud.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>bom</artifactId>
        <version>2.20.63</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>


  <build>
    <plugins>

      <!-- spring-boot-flyway-plugin -->
      <plugin>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-maven-plugin</artifactId>
        <configuration>
          <url>jdbc:h2:file:./target/data;MODE=mysql</url>
          <user>sa</user>
          <schemas>
            <schema>identity</schema>
          </schemas>
          <locations>
            <location>filesystem:./src/main/resources/database/migration</location>
          </locations>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.1.210</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
      </plugin>


      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>generate-docs</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>process-asciidoc</goal>
            </goals>
            <configuration>
              <backend>html</backend>
              <doctype>book</doctype>
              <sourceDocumentName>index.adoc</sourceDocumentName>
              <attributes>
                <snippets>${snippetsDirectory}</snippets>
              </attributes>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>
                ${project.build.outputDirectory}/static/docs
              </outputDirectory>
              <resources>
                <resource>
                  <directory>
                    ${project.build.directory}/generated-docs
                  </directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>generate-javadoc-json</id>
            <phase>compile</phase>
            <goals>
              <goal>javadoc-no-fork</goal>
            </goals>
            <configuration>
              <doclet>capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet</doclet>
              <docletArtifact>
                <groupId>capital.scalable</groupId>
                <artifactId>spring-auto-restdocs-json-doclet-jdk9</artifactId>
                <version>2.0.11</version>
              </docletArtifact>
              <destDir>generated-javadoc-json</destDir>
              <reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
              <useStandardDocletOptions>false</useStandardDocletOptions>
              <show>package</show>
            </configuration>
          </execution>
        </executions>
      </plugin>


      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>

          <execution>
            <id>post-unit-test</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <!-- Sets the path to the file which contains the execution
                data. -->
              <dataFile>target/jacoco.exec</dataFile>
              <!-- Sets the output directory for the code coverage report. -->
              <outputDirectory>target/jacoco-ut</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>pre-integration-test</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <destFile>${project.build.directory}/jacoco-it.exec</destFile>
              <append>true</append>
              <propertyName>failsafe.argLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>post-integration-test</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>report-aggregate</goal>
            </goals>
          </execution>
          <execution>
            <id>pull-test-data</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>dump</goal>
            </goals>
            <configuration>
              <destFile>${project.build.directory}/jacoco-it-${app.host}:${app.port}.exec</destFile>
              <address>${app.host}</address>
              <port>${app.port}</port>
              <reset>false</reset>
              <skip>${skip.dump}</skip>
            </configuration>
          </execution>
          <execution>
            <id>merge-test-data</id>
            <goals>
              <goal>merge</goal>
            </goals>
            <configuration>
              <destFile>target/jacoco-it.exec</destFile>
              <skip>${skip.dump}</skip>
              <fileSets>
                <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
                  <directory>target</directory>
                  <includes>
                    <include>*it*.exec</include>
                    <include>jacoco.exec</include>
                  </includes>
                </fileSet>
              </fileSets>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <append>true</append>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-jacoco</id>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <includeArtifactIds>org.jacoco.agent</includeArtifactIds>
              <includeClassifiers>runtime</includeClassifiers>
              <outputDirectory>${project.build.directory}/jacoco-agent</outputDirectory>
              <stripVersion>false</stripVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skipTests>false</skipTests>
          <forkCount>0</forkCount>
        </configuration>
      </plugin>
      <!-- checks dependencies for vulnerabilities -->
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>7.4.4</version>
        <configuration>
          <!-- Fail Build On CVSS core more then 8.0 which is HIGH-->
          <!-- <failBuildOnCVSS>8</failBuildOnCVSS> -->
          <!-- Generate all report formats -->
          <format>ALL</format>
          <!-- Don't use Nexus Analyzer -->
          <centralAnalyzerEnabled>false</centralAnalyzerEnabled>
          <ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
          <!-- Am I the latest version? -->
          <versionCheckEnabled>true</versionCheckEnabled>
          <!--suppression Files -->
          <suppressionFiles>src/main/resources/suppressed.xml</suppressionFiles>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <configuration>
          <transformationSets>
            <transformationSet>
              <dir>${project.build.directory}</dir>
              <includes>
                <include>dependency-check-report.xml</include>
              </includes>
              <stylesheet>src/main/resources/dependencycheck_to_pmd.xsl</stylesheet>
              <outputDir>target</outputDir>
              <fileMappers>
                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
                  <targetName>dependency-check-report-pmd.xml</targetName>
                </fileMapper>
              </fileMappers>
            </transformationSet>
          </transformationSets>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>net.sf.saxon</groupId>
            <artifactId>saxon</artifactId>
            <version>8.7</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>3.9.1.2184</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>


</project>
