<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.metricshub</groupId>
		<artifactId>metricshub-community</artifactId>
		<version>1.0.13</version>
	</parent>

	<artifactId>metricshub-engine</artifactId>

	<name>MetricsHub Engine</name>
	<description>MetricsHub Monitoring Engine</description>

	<dependencies>
		<dependency>
			<groupId>org.metricshub</groupId>
			<artifactId>metricshub-classloader-agent</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>compile</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.metricshub</groupId>
			<artifactId>jawk</artifactId>
		</dependency>
		<dependency>
			<groupId>org.metricshub</groupId>
			<artifactId>tablejoin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.metricshub</groupId>
			<artifactId>jflat</artifactId>
		</dependency>
		<dependency>
			<groupId>org.metricshub</groupId>
			<artifactId>xflat</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-params</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.opentelemetry.instrumentation</groupId>
			<artifactId>opentelemetry-instrumentation-annotations</artifactId>
		</dependency>
	</dependencies>

	<build>

		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
		</resources>

		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
			<testResource>
				<directory>src/it/resources</directory>
			</testResource>
		</testResources>

		<plugins>

			<!-- surefire -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<systemPropertyVariables>
						<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
					</systemPropertyVariables>
					<classpathDependencyExcludes>
						<classpathDependencyExclude>org.apache.logging.log4j:log4j-slf4j-impl</classpathDependencyExclude>
					</classpathDependencyExcludes>
					<argLine>@{argLine} -javaagent:"${org.mockito:mockito-core:jar}"</argLine>
				</configuration>
			</plugin>

			<!-- jacoco -->
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>default-prepare-agent</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
					</execution>
					<execution>
						<id>default-report</id>
						<goals>
							<goal>report</goal>
						</goals>
					</execution>
					<execution>
						<id>default-check</id>
						<goals>
							<goal>check</goal>
						</goals>
						<configuration>
							<rules>
								<rule>
									<element>BUNDLE</element>
									<limits>
										<limit>
											<counter>COMPLEXITY</counter>
											<value>COVEREDRATIO</value>
											<minimum>0.61</minimum>
										</limit>
									</limits>
								</rule>
							</rules>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<excludes>
						<!-- Exclude simple DTO, VO and POJO -->
						<exclude>org/metricshub/engine/connector/model/**</exclude>
						<exclude>org/metricshub/engine/client/**</exclude>
						<exclude>org/metricshub/engine/connector/model/common/**</exclude>
					</excludes>
				</configuration>
			</plugin>

			<!-- build-helper-maven-plugin -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<execution>
					<id>add-test-source</id>
					<phase>generate-test-sources</phase>
					<goals>
						<goal>add-test-source</goal>
					</goals>
					<configuration>
						<sources>
							<source>src/it/java</source>
						</sources>
					</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- The maven-invoker-plugin is required for extension system testing -->
			<plugin>
				<artifactId>maven-invoker-plugin</artifactId>
				<configuration>
					<debug>true</debug>
					<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
					<pomIncludes>
						<pomInclude>**/pom.xml</pomInclude>
					</pomIncludes>
					<projectsDirectory>src/it/resources/extensions</projectsDirectory>
					<postBuildHookScript>verify</postBuildHookScript>
					<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
					<settingsFile>src/it/resources/extensions/settings.xml</settingsFile>
					<goals>
						<goal>clean</goal>
						<goal>package</goal>
					</goals>
				</configuration>
				<executions>
					<execution>
						<id>integration-test</id>
						<goals>
							<goal>install</goal>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- failsafe -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<executions>
					<execution>
						<id>integration-test</id>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<forkCount>1</forkCount>
					<reuseForks>false</reuseForks>
					<argLine>@{argLine}</argLine>
					<includes>
						<include>**/*IT.java</include>
					</includes>
					<classesDirectory>${project.build.outputDirectory}</classesDirectory>
					<trimStackTrace>false</trimStackTrace>
				</configuration>
			</plugin>

			<!-- MetricsHub Engine Jar -->
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<id>no-slf4j-impl-jar</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>src/assembly/no-slf4j-impl-jar.xml</descriptor>
							</descriptors>
							<appendAssemblyId>true</appendAssemblyId>
						</configuration>
					</execution>
				</executions>
			</plugin>

		</plugins>

	</build>
</project>