<!--
  #%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.20.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>
	<profiles>
		<profile>
			<id>spotbugs</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.spotbugs</groupId>
						<artifactId>spotbugs-maven-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<dependencies>
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<!-- Enforce failure is 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>
			</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 -XX:MaxPermSize=256m ${surefireArgs}</argLine>
				</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>
