<!--
- Copyright (c) 2010, 2011 SAP AG and others.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- https://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
-    SAP AG - initial API and implementation
-->

<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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>org.eclipse.tycho.extras</groupId>
		<artifactId>tycho-extras</artifactId>
		<version>4.0.10</version>
	</parent>

	<artifactId>tycho-p2-extras-plugin</artifactId>
	<packaging>maven-plugin</packaging>

	<name>Tycho p2 Extras Plugin</name>
	<prerequisites>
		<maven>${minimal-maven-version}</maven>
	</prerequisites>
	<properties>
		<tycho-build-version>${project.version}</tycho-build-version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.apache.maven.plugin-tools</groupId>
			<artifactId>maven-plugin-annotations</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-artifact</artifactId>
		</dependency>
		<dependency>
			<groupId>org.eclipse.tycho</groupId>
			<artifactId>tycho-artifactcomparator</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.tycho</groupId>
			<artifactId>tycho-testing-harness</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.eclipse.tycho</groupId>
			<artifactId>sisu-equinox-launching</artifactId>
		</dependency>

        <dependency>
            <!--
                Workaround 387848 and 348394.

                Ideally, we want to be able to run unit/integration tests in three distinct environments
                - on CI system, when tycho-core dependencies are resolved from remote repositories
                - on dev machine, when tycho-core is installed in local repository or resolved from repositories
                - from within m2e workspace, when tycho-core is resolved according to m2e workspace resolution rules

                Due to a limitation in Maven core, it is not possible to force a Maven build to use
                locally cached but not installed artifacts. This means that tests MUST be able to resolve tycho-core
                artifacts remotely, although Maven will skip actual remote download if artifacts are already cached 
                locally.

                The workaround for this limitation is two step
                - this dependency gives maven-invoker has access to all classes required to perform artifact resolution
                  from remote repositories.
                - new snapshots/releases <pluginRepository> in test pom.xml files gives test project access to
                  tycho-core artifacts
             -->
            <groupId>org.apache.maven</groupId>
            <artifactId>apache-maven</artifactId>
            <version>${maven-version}</version>
            <classifier>bin</classifier>
            <type>tar.gz</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
        	<groupId>org.eclipse.tycho</groupId>
        	<artifactId>tycho-core</artifactId>
        </dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.codehaus.plexus</groupId>
				<artifactId>plexus-component-metadata</artifactId>
			</plugin>
			<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>maven-properties-plugin</artifactId>
				<version>0.0.2</version>
				<executions>
					<execution>
						<phase>process-test-resources</phase>
						<goals>
							<goal>filter-file</goal>
						</goals>
						<configuration>
							<in>src/test/resources/baseTest.properties</in>
							<outDir>target/test-classes/</outDir>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- During the unit tests, the test project is copied to the target folder 
				and the publish mojo is executed on the project. The test project may also 
				be built directly from the command line. This configuration makes sure that 
				the target folder from a direct invocation is removed. Otherwise it may interfere 
				with the target folder created during the unit tests. -->
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<configuration>
					<filesets>
						<fileset>
							<directory>src/test/resources/</directory>
							<includes>
								<include>**/testProject/target/</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-plugin-plugin</artifactId>
				<!-- workaround for https://issues.apache.org/jira/browse/MPLUGIN-450 -->
				<configuration>
					<goalPrefix>tycho-p2-extras</goalPrefix>
				</configuration>
			</plugin>
		</plugins>
	</build>
	
	<profiles>
		<profile>
			<id>its</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-invoker-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
