<?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 https://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.4.10</version>
  </parent>

  <groupId>io.netfoundry</groupId>
  <artifactId>customer-management</artifactId>
  <version>0.0.4-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <timestamp>${maven.build.timestamp}</timestamp>
    <java.version>21</java.version>
    <maven.compiler.release>21</maven.compiler.release>
    
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
    <application.version.number>${project.version}</application.version.number>
    
    <spring-cloud.version>2024.0.1</spring-cloud.version>
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
    <sonar.organization>netfoundry</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.coverage.exclusions>
      **/config/*, **/service/**/*
    </sonar.coverage.exclusions>
    <jacoco.version>0.8.11</jacoco.version>
    
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
    <cms.openapi.version>0.1.0</cms.openapi.version>
  </properties>


  <dependencies>

    <!-- NetFoundry Dependencies -->

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>common-util-framework</artifactId>
      <version>4.1.10</version>
    </dependency>

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>authorization</artifactId>
      <version>2.8.2</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>
        <exclusion>
          <groupId>io.netfoundry</groupId>
          <artifactId>common-util-framework</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>process-framework</artifactId>
      <version>0.37.0</version>
    </dependency>

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

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

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

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

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</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.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
    </dependency>

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

    <dependency>  <!-- Metrics reporting -->
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-registry-elastic</artifactId>
    </dependency>
    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-tracing-bridge-brave</artifactId>
    </dependency>

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

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

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

    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-csv</artifactId>
    </dependency>

    <dependency> <!-- Caching -->
      <groupId>com.github.ben-manes.caffeine</groupId>
      <artifactId>caffeine</artifactId>
    </dependency>

    <dependency> <!-- required for Common's ParameterStoreTemplate -->
      <groupId>net.jodah</groupId>
      <artifactId>failsafe</artifactId>
      <version>2.4.4</version>
    </dependency>

    <dependency>
      <groupId>commons-validator</groupId>
      <artifactId>commons-validator</artifactId>
      <version>1.8.0</version>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
      <scope>provided</scope>
    </dependency>


    <!-- OpenApi -->
    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
      <version>2.8.9</version>
    </dependency>

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-hateoas</artifactId>
      <version>1.8.0</version>
    </dependency>

    <!-- Lombok -->
    
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>compile</scope>
    </dependency>
    
    
    <!-- Simple Mail FW -->

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

    <!-- Persistence Dependencies -->

    <dependency>
      <groupId>com.mysql</groupId>
      <artifactId>mysql-connector-j</artifactId>
    </dependency>

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


    <!-- Redisson -->

    <dependency>
      <groupId>org.redisson</groupId>
      <artifactId>redisson-spring-boot-starter</artifactId>
      <version>3.26.1</version>
    </dependency>

    
    <!--  AWS -->

    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>s3</artifactId>
      <exclusions>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

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

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

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

    <dependency>  <!-- key generator for small(er) ids than UUID -->
      <groupId>com.aventrix.jnanoid</groupId>
      <artifactId>jnanoid</artifactId>
      <version>2.0.0</version>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>33.0.0-jre</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-text</artifactId>
      <version>1.13.1</version>
    </dependency>

    <dependency>  <!-- parsing and validation of json schema -->
      <groupId>com.networknt</groupId>
      <artifactId>json-schema-validator</artifactId>
      <version>1.1.0</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
    </dependency>

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

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <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>

    <dependency>
      <groupId>com.github.codemonstur</groupId>
      <artifactId>embedded-redis</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Documentation -->
    
    <dependency>
      <groupId>org.springframework.restdocs</groupId>
      <artifactId>spring-restdocs-mockmvc</artifactId>
    </dependency>
    
    <dependency>
      <groupId>capital.scalable</groupId>
      <artifactId>spring-auto-restdocs-core</artifactId>
      <version>2.0.5</version>
      <scope>test</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>
      <!--  provides Spring Boot support in Maven, letting you package executable jar or war archives and run an application “in-place” -->
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>build-info</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- will provide git information in the healthcheck endpoint -->
      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <version>4.9.10</version>
      </plugin>

      <!-- Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports. -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
          </includes>
          <systemPropertyVariables>
            <org.springframework.restdocs.outputDir>
              ${project.build.directory}/generated-snippets
            </org.springframework.restdocs.outputDir>
            <org.springframework.restdocs.javadocJsonDir>
              ${project.build.directory}/generated-javadoc-json
            </org.springframework.restdocs.javadocJsonDir>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
        <executions>
          <execution>
            <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>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>3.10.0.2594</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>docs</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>delombok</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <addOutputDirectory>false</addOutputDirectory>
              <outputDirectory>${project.build.directory}/generated-sources/delombok</outputDirectory>
              <sourceDirectory>src/main/java</sourceDirectory>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <sourcepath>${project.build.directory}/generated-sources/delombok</sourcepath>
              <additionalJOption>-Xdoclint:none</additionalJOption>
              <verbose>true</verbose>
            </configuration>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>generate-javadoc-json</id>
                <phase>compile</phase>
                <goals>
                  <goal>javadoc-no-fork</goal>
                  <goal>test-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.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>2.2.3</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-generated-api-docs-to-static-docs</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>
              <execution>
                <id>copy-redocs-to-static-docs</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-snippets</directory>
                      <includes>
                        <include>**/*.redoc</include>
                      </includes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>dependency_check</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <version>9.0.9</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>
      </build>
    </profile>
  </profiles>
</project>
