<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>

	<artifactId>de.rcenvironment.build.common.parent.osgiProject</artifactId>
	<name>RCE Parent POMs - Common - OSGi Project Base</name>
	<packaging>pom</packaging>

	<parent>
		<groupId>de.rcenvironment</groupId>
		<artifactId>de.rcenvironment.build.common.parent.basicSettings</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<relativePath>../basicSettings</relativePath>
	</parent>

	<profiles>
	
		<!-- If the property "rce.maven.repositories.foundation.url" is defined, add it as
			a p2 repository source; for target platform or "intermediate" repositories. -->
		<profile>
			<id>repositories.foundation</id>
			<activation>
				<property>
					<name>rce.maven.repositories.foundation.url</name>
				</property>
			</activation>
			<repositories>
				<repository>
					<id>repositories.foundation</id>
					<layout>p2</layout>
					<url>${rce.maven.repositories.foundation.url}</url>
					<snapshots>
						<!-- prevent Maven from using this repository for snapshot parent POMs 
							(which produces a warning as the layout is not recognized) -->
						<enabled>false</enabled>
					</snapshots>
				</repository>
			</repositories>
		</profile>

		<!-- This profile checks if a lib/maven/autoCopy.flag file exists in the 
			project, and if there is, all Maven dependencies are copied to lib/maven. 
			This is intended for embedding JARs into OSGi bundles without placing common 
			binaries under source control (where they don't belong). - misc_ro -->
		<profile>
			<id>auto-copy-maven-dependencies-to-lib-maven-if-present</id>
			<activation>
				<file>
					<exists>lib/maven/autoCopy.flag</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-clean-plugin</artifactId>
						<executions>
							<execution>
								<id>clean-jars-from-lib-maven</id>
								<goals>
									<goal>clean</goal>
								</goals>
								<phase>clean</phase>
								<configuration>
									<filesets>
										<fileset>
											<directory>${basedir}/lib/maven</directory>
											<includes>
												<include>*.jar</include>
											</includes>
											<followSymlinks>false</followSymlinks>
										</fileset>
									</filesets>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-dependency-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-maven-dependencies-to-lib-maven</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>copy-dependencies</goal>
								</goals>
								<configuration>
									<outputDirectory>${basedir}/lib/maven</outputDirectory>
									<!-- This is a workaround for the (weird) fact that maven-dependency-plugin 
										does not allow exclusion of more than one scope. When used together with 
										Tycho, however, it is necessary to exclude both "system" and "provided" scopes. 
										"runtime" achieves this, as it only includes "runtime" and "compile", unlike 
										"compile", which also includes "system" and "provided". It has already been 
										pointed out that this is highly unintuitive; see http://jira.codehaus.org/browse/MDEP-128 
										for discussion. - R. Mischke, Feb 2012 -->
									<includeScope>runtime</includeScope>
									<excludeTransitive>false</excludeTransitive>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
	</profiles>

	<build>
		<plugins>
			<!-- activate the Tycho plugins -->
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-compiler-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
			</plugin>
		</plugins>
	</build>
	
</project>
