<?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.0.6</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>io.netfoundry.gateway</groupId>
	<artifactId>GatewayApplication</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>GatewayApplication</name>
	<description>NF API Gateway</description>
	<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>

		<!-- Basic settings -->
		<spring-cloud.version>2022.0.1</spring-cloud.version>
		<java.version>17</java.version>
		<maven.compiler.release>17</maven.compiler.release>
		<sonar.organization>netfoundry</sonar.organization>
		<sonar.host.url>https://sonarcloud.io</sonar.host.url>
		<sonar.projectKey>netfoundry_gateway</sonar.projectKey>
		<sonar.sources>src/main</sonar.sources>
		<sonar.tests>src/test</sonar.tests>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<skip.dump>true</skip.dump>
		<sonar.jacoco.reportPaths>${basedir}/target/jacoco.exec,${basedir}/target/jacoco-it.exec</sonar.jacoco.reportPaths>
		<!-- Sonar, Lint, Java Code Coverage settings. These apply to build time only. -->
		<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
		<sonar.coverage.exclusions>src/main/java/io/netfoundry/gateway/GatewayApplication.java</sonar.coverage.exclusions>
	</properties>

	<dependencies>

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

		<dependency>
			<groupId>io.netfoundry</groupId>
			<artifactId>authorization</artifactId>
			<version>2.0.1</version>
			<classifier>client</classifier>
		</dependency>

		<!-- Spring Dependencies -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-logging</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-gateway</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<dependency>
			<groupId>io.projectreactor</groupId>
			<artifactId>reactor-core</artifactId>
			<version>3.5.5</version>
		</dependency>
		<dependency>  <!-- Metrics reporting -->
			<groupId>io.micrometer</groupId>
			<artifactId>micrometer-registry-elastic</artifactId>
		</dependency>
		<dependency>
			<groupId>io.micrometer</groupId>
			<artifactId>micrometer-observation</artifactId>
		</dependency>
		<dependency>
			<groupId>io.micrometer</groupId>
			<artifactId>micrometer-tracing</artifactId>
		</dependency>
		<dependency>
			<groupId>io.micrometer</groupId>
			<version>1.0.4</version>
			<artifactId>context-propagation</artifactId>
		</dependency>
		<dependency>
			<groupId>io.micrometer</groupId>
			<artifactId>micrometer-tracing-bridge-brave</artifactId>
		</dependency>

		<!-- Logstash encoder brings with it jackson-core 2.14.2
			- This version has an open cve - CVE-2022-45688
			- There is an overflow in the toJSONObject method.
			- Code analysis shows that the logback encoder does not use this method
			- so is not vulnerable. Any updates to this library require
			- similar analysis.
		-->
		<dependency>
			<groupId>net.logstash.logback</groupId>
			<artifactId>logstash-logback-encoder</artifactId>
			<version>7.3</version>
		</dependency>

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

		<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>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>io.github.resilience4j</groupId>
			<artifactId>resilience4j-circuitbreaker</artifactId>
		</dependency>

		<dependency>
			<groupId>net.jodah</groupId>
			<artifactId>failsafe</artifactId>
			<version>2.4.4</version>
		</dependency>

		<!-- Redisson -->
		<dependency>
			<groupId>org.redisson</groupId>
			<artifactId>redisson-spring-boot-starter</artifactId>
			<version>3.19.0</version>
		</dependency>

		<!-- Auth0 -->

		<dependency>
			<groupId>com.auth0</groupId>
			<artifactId>java-jwt</artifactId>
			<version>3.19.1</version>
		</dependency>

		<dependency>
			<groupId>com.auth0</groupId>
			<artifactId>jwks-rsa</artifactId>
			<version>0.21.2</version>
		</dependency>

		<!-- Amazon SDKs -->

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

		<!-- Testing -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<version>4.6.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.13.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>it.ozimov</groupId>
			<artifactId>embedded-redis</artifactId>
			<version>0.7.3</version>
			<scope>test</scope>
		</dependency>

		<!-- Runtime Misc -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>provided</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>

			<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.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>0.8.8</version>
				<executions>
					<execution>
						<id>pre-unit-test</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
					</execution>
					<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>
				<version>2.22.1</version>
				<configuration>
				    <includes>
					    <include>**/*Test.java,*Test.java</include>
					</includes>
					<!-- <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 -->
					<ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
					<centralAnalyzerEnabled>false</centralAnalyzerEnabled>
					<!-- Am I the latest version? -->
					<versionCheckEnabled>true</versionCheckEnabled>
					<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>
