<?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 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.googlecode.cmake-maven-project</groupId>
		<artifactId>cmake</artifactId>
		<version>3.16.3-b2</version>
	</parent>
	<prerequisites>
		<maven>${maven.version}</maven>
	</prerequisites>
	<artifactId>cmake-maven-plugin</artifactId>
	<packaging>maven-plugin</packaging>
	<name>CMake Maven Plugin</name>
	<description>Builds native code using CMake makefile generator</description>
	<build>
		<!-- Filter the settings.xml file but not the test projects -->
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<includes>
					<include>settings.xml</include>
				</includes>
				<filtering>true</filtering>
			</testResource>
			<testResource>
				<directory>src/test/resources</directory>
				<excludes>
					<exclude>settings.xml</exclude>
				</excludes>
				<filtering>false</filtering>
			</testResource>
		</testResources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-plugin-plugin</artifactId>
				<configuration>
					<goalPrefix>cmake</goalPrefix>
				</configuration>
				<executions>
					<execution>
						<id>default-descriptor</id>
						<goals>
							<goal>descriptor</goal>
						</goals>
						<phase>process-classes</phase>
					</execution>
					<execution>
						<id>help-descriptor</id>
						<goals>
							<goal>helpmojo</goal>
						</goals>
						<phase>process-classes</phase>
					</execution>
				</executions>
			</plugin>
			<!-- Install the cmake-maven-plugin to the test repository -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-install-plugin</artifactId>
				<executions>
					<execution>
						<id>install-plugin-for-it</id>
						<goals>
							<goal>install-file</goal>
						</goals>
						<phase>pre-integration-test</phase>
						<configuration>
							<file>${project.build.directory}/${project.build.finalName}.jar</file>
							<generatePom>true</generatePom>
							<pomFile>pom.xml</pomFile>
							<packaging>jar</packaging>
							<version>${project.version}</version>
							<localRepositoryPath>${test-repo}</localRepositoryPath>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- Copy cmake-maven-plugin dependencies to the test repository -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-it-dependencies</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>copy-dependencies</goal>
							<!-- There is a go-offline goal but it's broken
							https://issues.apache.org/jira/browse/MDEP-82 -->
						</goals>
						<configuration>
							<outputDirectory>${test-repo}</outputDirectory>
							<useRepositoryLayout>true</useRepositoryLayout>
							<addParentPoms>true</addParentPoms>
							<copyPom>true</copyPom>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- Integration testing of cmake-maven-plugin's mojos -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<executions>
					<execution>
						<id>default-test</id>
						<goals>
							<goal>test</goal>
						</goals>
						<phase>integration-test</phase>
						<configuration>
							<!-- Our tests shouldn't be run as unit tests -->
							<includes>
								<include>**/*IntegrationSuite.java</include>
							</includes>
							<excludes>
								<exclude>**/*IntegrationTest.java</exclude>
							</excludes>
							<systemPropertyVariables>
								<!-- Pass parameters onto our test projects -->
								<cmake.plugin.groupid>${project.groupId}</cmake.plugin.groupid>
								<cmake.plugin.version>${project.version}</cmake.plugin.version>
								<platform>${platform}</platform>
							</systemPropertyVariables>
							<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
							<trimStackTrace>false</trimStackTrace>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>org.twdata.maven</groupId>
			<artifactId>mojo-executor</artifactId>
			<version>2.3.1</version>
		</dependency>

		<!-- Upgrade transitive dependency of maven-plugin-plugin to avoid parsing error for Java9+ classes -->
		<dependency>
			<groupId>org.sonatype.sisu</groupId>
			<artifactId>sisu-inject-plexus</artifactId>
			<version>2.6.0</version>
		</dependency>

		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-core</artifactId>
			<version>${maven.core.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.plugin-tools</groupId>
			<artifactId>maven-plugin-annotations</artifactId>
			<version>${maven.plugin.annotations.version}</version>
		</dependency>
		<dependency>
			<groupId>org.bitbucket.cowwoc.pouch</groupId>
			<artifactId>pouch</artifactId>
			<version>1.14</version>
		</dependency>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>cmake-common</artifactId>
			<version>${project.version}</version>
		</dependency>
		<!-- Below here are testing dependencies -->
		<dependency>
			<groupId>org.apache.maven.shared</groupId>
			<artifactId>maven-verifier</artifactId>
			<version>1.6</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.12</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<!-- Run tests from ${test-repo} repository instead of the local repo -->
	<properties>
		<test-repo>${project.build.directory}/test-classes/test-repo</test-repo>
	</properties>

	<profiles>
		<profile>
			<id>windows-x86_64</id>
			<activation>
				<os>
					<family>windows</family>
					<arch>amd64</arch>
				</os>
			</activation>
			<dependencies>
				<dependency>
					<groupId>${project.groupId}</groupId>
					<artifactId>cmake-binaries</artifactId>
					<version>${project.version}</version>
					<classifier>${platform}</classifier>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>
		<profile>
			<id>linux-x86_64</id>
			<activation>
				<os>
					<family>linux</family>
					<arch>amd64</arch>
				</os>
			</activation>
			<dependencies>
				<dependency>
					<groupId>${project.groupId}</groupId>
					<artifactId>cmake-binaries</artifactId>
					<version>${project.version}</version>
					<classifier>${platform}</classifier>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>
		<profile>
			<id>linux-arm</id>
			<activation>
				<os>
					<family>linux</family>
					<arch>arm</arch>
				</os>
			</activation>
			<properties>
				<download.cmake>false</download.cmake>
			</properties>
		</profile>
		<profile>
			<id>mac-x86_64</id>
			<activation>
				<os>
					<family>mac</family>
					<arch>x86_64</arch>
				</os>
			</activation>
			<dependencies>
				<dependency>
					<groupId>${project.groupId}</groupId>
					<artifactId>cmake-binaries</artifactId>
					<version>${project.version}</version>
					<classifier>${platform}</classifier>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>
	</profiles>
</project>
