<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.2.1</version>
  </parent>


  <groupId>io.netfoundry</groupId>
  <artifactId>messaging-framework</artifactId>
  <version>0.8.0-SNAPSHOT</version>
  <name>Platform Messaging Framework</name>


  <properties>
    <!-- Timestamp and application version number are injected into the application
      and bootstrap properties files, and used for logging purposes ... to track
      build version that the logs were made against. -->
    <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>21</java.version>
    <maven.compiler.release>21</maven.compiler.release>

    <!-- JUnit version -->
    <junit-jupiter.version>5.10.2</junit-jupiter.version>

    <!-- Sonar, Lint, Java Code Coverage settings. These apply to build time
      only. -->
    <sonar.jacoco.reportPaths>${basedir}/target/jacoco.exec,${basedir}/target/jacoco-it.exec</sonar.jacoco.reportPaths>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.organization>netfoundry</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.projectName>messaging-framework</sonar.projectName>
    <sonar.sources>src/main</sonar.sources>
    <sonar.tests>src/test</sonar.tests>
    <sonar.coverage.exclusions>
      **/config/*
    </sonar.coverage.exclusions>
    <sonar.cpd.exclusions></sonar.cpd.exclusions>
  </properties>


  <dependencies>

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>common-util-framework</artifactId>
      <version>3.0.0-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.netfoundry</groupId>
      <artifactId>authorization</artifactId>
      <version>3.0.0</version>
      <classifier>client</classifier>
      <!-- A Service which depends on messaging may optionally directly declare and
        provide the authorization client, and this messaging service will detect and
        use it if present.  -->
      <scope>provided</scope>
    </dependency>

    <!-- Spring Dependencies -->

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

    <dependency>
      <groupId>org.springframework.amqp</groupId>
      <artifactId>spring-rabbit</artifactId>
    </dependency>

    <dependency>
      <groupId>jakarta.validation</groupId>
      <artifactId>jakarta.validation-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>jakarta.annotation</groupId>
      <artifactId>jakarta.annotation-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.hibernate.validator</groupId>
      <artifactId>hibernate-validator</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <!-- Yes, this looks weird, but there's a very good reason.  SpringBoot will
        auto-configure a Jackson ObjectMapper via the
        org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
        class CONDITIONALLY on the class path containing this class
        org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.
        That class is from the Spring FW Web project (see the http package?).
        I think this is effectively a defect in spring boot's auto-configuration,
        but I can't fix that.  Alas, we only need Spring Boot to auto-configure
        an ObjectMapper during tests when checking configurations under a default
        Spring Boot context. Thus, this web dependency is just for tests and even
        then, just to get the Jackson2ObjectMapperBuilder into the classpath. -->
      <scope>test</scope>
    </dependency>

    <!-- Misc. Minor Dependencies -->

    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
      <scope>provided</scope>
    </dependency>

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

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

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

    <!-- Logging API and implementation dependencies -->
    <dependency>
      <groupId>net.logstash.logback</groupId>
      <artifactId>logstash-logback-encoder</artifactId>
      <version>7.3</version>
      <scope>provided</scope>
    </dependency>

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


    <!-- Testing Dependencies -->

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

    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>rabbitmq</artifactId>
      <version>[1.16.2,)</version>
      <scope>test</scope>
    </dependency>

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

  </dependencies>


  <build>
    <plugins>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <configuration></configuration>
      </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>
        </configuration>
       
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.11</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>
      <!-- checks dependencies for vulnerabilities -->
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>7.4.4</version>
        <configuration>
          <format>ALL</format>
          <!-- Don't use Nexus Analyzer -->
          <ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
          <centralAnalyzerEnabled>false</centralAnalyzerEnabled>
          <!-- 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>
