<!--
  #%L
  %%
  Copyright (C) 2021 BMW Car IT GmbH
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<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">
	<artifactId>java</artifactId>
	<modelVersion>4.0.0</modelVersion>
	<packaging>pom</packaging>
	<name>${project.groupId}:${project.artifactId}</name>

	<parent>
		<groupId>io.joynr</groupId>
		<artifactId>dependency-lock</artifactId>
		<version>1.23.0</version>
		<relativePath>../dependency-lock/pom.xml</relativePath>
	</parent>

	<modules>
		<module>backend-services</module>
		<module>common</module>
		<module>core</module>
		<module>javaapi</module>
		<module>jeeintegration</module>
		<module>messaging</module>
		<module>integration-tests</module>
		<module>coverage</module>
	</modules>
	<properties>
		<sonar.moduleKey>${sonar.projectKey}:${project.groupId}:${project.artifactId}</sonar.moduleKey>
	</properties>
	<profiles>
		<profile>
			<id>spotbugs</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.spotbugs</groupId>
						<artifactId>spotbugs-maven-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>sonarsource-scanner-maven</id>
				<properties>
					<java.version>1.11</java.version>
					<sonar.language>java</sonar.language>
					<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
					<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
					<sonar.coverage.jacoco.xmlReportPaths>**/src/**/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
					<sonar.java.binaries>**/src/**/target/classes/**/*.class</sonar.java.binaries>
					<sonar.java.libraries>
							**/src/**/target/*.jar,
							**/src/**/target/deploy/*.jar
					</sonar.java.libraries>
					<sonar.java.test.binaries>**/src/**/target/*-tests.jar</sonar.java.test.binaries>
					<sonar.jacoco.reportsPaths>**/src/**/target/site/jacoco/jacoco.xml</sonar.jacoco.reportsPaths>
					<sonar.tests>
						**/src/test/java,
						**/src/integrationTest/**
					</sonar.tests>
					<sonar.exclusions>
						**/src/**/target/*-sources.jar,
						**/target/test-classes/**/*,
						**/test/**,
						<!--The following classes are excluded from sonarqube analysis because they do not have tests -->
						**/src/**/ClusterController.java,
						**/src/**/StaticDomainAccessControlProvisioning.java,
						**/src/**/LowerCaseProperties.java,
						**/src/**/CCInProcessRuntimeModule.java,
						**/src/**/CCWebSocketRuntimeModule.java,
						**/src/**/LibjoynrWebSocketRuntimeModule.java,
						**/src/**/WebSocketJettyClient.java,
						**/src/**/WebSocketJettyServer.java
					</sonar.exclusions>
					<sonar.test.exclusions>
						**/test/**
					</sonar.test.exclusions>
				</properties>
		</profile>
	</profiles>
	<dependencies>
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<!-- Enforce failure if dependency check fails -->
				<!-- Can optionally be moved up to parent pom -->
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-dependency-plugin</artifactId>
					<executions>
						<execution>
							<id>analyze</id>
							<goals>
								<goal>analyze-only</goal>
							</goals>
							<configuration>
								<failOnWarning>true</failOnWarning>
							</configuration>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-test-sources</id>
						<goals>
							<goal>test-jar-no-fork</goal>
						</goals>
						<configuration>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>net.revelc.code.formatter</groupId>
				<artifactId>formatter-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<executions>
					<execution>
						<id>enforce-java-version</id>
						<goals>
							<goal>enforce</goal>
						</goals>
						<phase>validate</phase>
						<configuration>
							<rules>
								<requireJavaVersion>
									<version>${generic.requireJavaVersion}</version>
									<message>Wrong java version. You must use Java ${generic.requireJavaVersion} to build joynr.</message>
								</requireJavaVersion>
							</rules>
						</configuration>
					</execution>
					<execution>
						<id>enforce-bytecode-version</id>
						<configuration>
							<rules>
								<enforceBytecodeVersion>
									<maxJdkVersion>${generic.enforceByteCode.maxJdkVersion}</maxJdkVersion>
								</enforceBytecodeVersion>
							</rules>
						</configuration>
						<goals>
							<goal>enforce</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<configuration>
					<verbose>false</verbose>
					<failOnError>true</failOnError>
					<sourcepath>${basedir}</sourcepath>
					<sourceFileExcludes>
						<exclude>**/target/**/*.java</exclude>
						<exclude>**/src/test/**/*.java</exclude>
						<exclude>integration-tests/src/main/**/*.java</exclude>
						<!-- following files will be quelled, since the package-info is duplicated -->
						<exclude>**/package-info.java</exclude>
					</sourceFileExcludes>
					<detectJavaApiLink>true</detectJavaApiLink>
					<detectLinks>true</detectLinks>
					<additionalDependencies>
						<additionalDependency>
							<groupId>org.hamcrest</groupId>
							<artifactId>hamcrest-core</artifactId>
							<version>1.3</version>
						</additionalDependency>
						<additionalDependency>
							<groupId>junit</groupId>
							<artifactId>junit</artifactId>
							<version>4.13.1</version>
						</additionalDependency>
						<additionalDependency>
							<groupId>io.joynr.java</groupId>
							<artifactId>javaapi</artifactId>
							<version>${project.version}</version>
							<type>test-jar</type>
						</additionalDependency>
					</additionalDependencies>
				</configuration>
				<executions>
					<execution>
						<id>aggregate</id>
						<phase>site</phase>
						<goals>
							<goal>aggregate-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>prepare-agent</id>
						<phase>initialize</phase>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
						<configuration>
							<destFile>${project.build.directory}/jacoco/execution-data</destFile>
							<propertyName>surefireArgs</propertyName>
							<skip>${skipTests}</skip>
						</configuration>
					</execution>
					<execution>
						<id>report</id>
						<phase>verify</phase>
						<goals>
							<goal>report</goal>
						</goals>
						<configuration>
							<dataFile>${project.build.directory}/jacoco/execution-data</dataFile>
							<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
							<skip>${skipTests}</skip>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration combine.children="override">
					<argLine>-Xmx1024m ${surefireArgs}</argLine>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<configuration>
					<filesets combine.children="append">
						<fileset>
							<directory>src/main/generated</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>src/test/generated</directory>
							<includes>
								<include>**</include>
							</includes>
						</fileset>
						<fileset>
							<directory>${project.basedir}</directory>
							<includes>
								<include>joynr.properties</include>
								<include>joynr_participantIds.properties</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>

			<!-- enforce dependency check -->
			<!-- optionally this can be moved up, together with pluginManagement for this plugin -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
			</plugin>

		</plugins>
	</build>
</project>
