<?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.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>io.netfoundry</groupId>
    <artifactId>reporting</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>reporting</name>
    <description>Netfoundry Reporting Service</description>

    <properties>
        <java.version>21</java.version>
        <maven.compiler.release>21</maven.compiler.release>
        <!-- sonar configuration -->
        <sonar.projectName>reporting</sonar.projectName>
        <sonar.projectKey>netfoundry_reporting</sonar.projectKey>
        <sonar.organization>netfoundry</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <sonar.sources>src/main</sonar.sources>
        <sonar.tests>src/test</sonar.tests>
        <jacoco.version>0.8.11</jacoco.version>
        <spring-ai.version>1.1.8</spring-ai.version>
        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
        <sonar.coverage.exclusions>
            **/config/*,**/service/*,**/exception/*
        </sonar.coverage.exclusions>
    </properties>


    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ai</groupId>
                <artifactId>spring-ai-bom</artifactId>
                <version>${spring-ai.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- NetFoundry Dependencies -->
        <dependency>
            <groupId>io.netfoundry</groupId>
            <artifactId>common-util-framework</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.netfoundry</groupId>
            <artifactId>authorization</artifactId>
            <version>2.5.0</version>
            <classifier>client</classifier>
            <exclusions>
                <exclusion>
                    <groupId>io.netfoundry</groupId>
                    <artifactId>common-util-framework</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

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

        <!-- MCP server (in-process, HTTP/SSE transport over the existing servlet stack) -->
        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-starter-mcp-server-webmvc</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-actuator</artifactId>
        </dependency>

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

        <!-- Additional Content Encoding Support -->

        <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>

        <!-- Elastic Search Client -->
        <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
        </dependency>

        <!-- Metrics -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-elastic</artifactId>
        </dependency>

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

        <!-- Miscelaneous 3rd party Dependencies -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency> <!-- NF common-util-framework Rest Service Client requires Http Client v5. -->
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
        </dependency>

        <dependency>
            <groupId>org.atteo</groupId>
            <artifactId>evo-inflector</artifactId>
            <version>1.3</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <version>7.4</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>org.springframework.boot</groupId>
            <artifactId>spring-boot-testcontainers</artifactId>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>elasticsearch</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>3.10.0.2594</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <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>
            <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>
    </build>

    <profiles>
        <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 File -->
                            <suppressionFiles>owasp/suppressed-dependencies.xml</suppressionFiles>
                        </configuration>
                    </plugin>

                    <!-- transform  (using XSLT) the dependency-check-report.xml file into dependency-check-report-pmd.xml -->
                    <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>owasp/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>
