<?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/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>
	<groupId>tools.vitruv</groupId>
	<artifactId>parent</artifactId>
	<version>0.1.0</version>
	<name>${project.artifactId}</name>
	<description>A common parent POM for all builds of viruv.tools</description>
	<url>http://vitruv.tools</url>
	<packaging>pom</packaging>

	<licenses>
		<license>
			<name>Eclipse Public License - v 2.0</name>
			<url>https://www.eclipse.org/legal/epl-2.0/</url>
		</license>
	</licenses>

	<developers>
		<developer>
			<name>Heiko Klare</name>
			<email>heiko.klare@kit.edu</email>
			<organization>Karlsruhe Institute of Technology (KIT), Germany</organization>
			<organizationUrl>http://kit.edu</organizationUrl>
		</developer>
	</developers>
	
	<scm>
		<connection>scm:git:git://github.com/vitruv-tools/Maven-Build-Parents.git</connection>
		<developerConnection>scm:git:ssh://github.com/vitruv-tools/Maven-Build-Parents.git</developerConnection>
		<url>http://github.com/vitruv-tools/Maven-Build-Parents/tree/master</url>
	</scm>
	
	<properties>
		<tycho.version>1.3.0</tycho.version>
		<xtext.version>2.16.0</xtext.version>
	</properties>
	
	<repositories>
		<repository>
			<id>Eclipse 4.10 (2018-12)</id>
			<layout>p2</layout>
			<!--<url>http://download.eclipse.org/releases/2018-12</url>-->
			<url>http://ftp-stud.hs-esslingen.de/pub/Mirrors/eclipse/releases/2018-12/</url>
		</repository>
		<repository>
			<id>Eclipse 4.10 Updates</id>
			<layout>p2</layout>
			<url>http://download.eclipse.org/eclipse/updates/4.10</url>
		</repository>
		<repository>
			<id>Vitruv License</id>
			<layout>p2</layout>
			<url>http://vitruv-tools.github.io/updatesite/release/license</url>
		</repository>
	</repositories>

	<profiles>
		<!-- Build configuration of parent POM itself -->
		<profile>
			<id>local-build</id>
			<activation>
				<file>
					<exists>.maven_local-build</exists>
				</file>
			</activation>
			<distributionManagement>
				<snapshotRepository>
					<id>ossrh</id>
					<url>https://oss.sonatype.org/content/repositories/snapshots</url>
				</snapshotRepository>
				<repository>
					<id>ossrh</id>
					<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
				</repository>
			</distributionManagement>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>1.6</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Run "mvn clean deploy -P release" to a release with this profile -->
		<profile>
			<id>release</id>
			<activation>
				<property>
					<name>release</name>
				</property>
			</activation>
			<build>
				<plugins>
				<!-- To release to Maven central -->
					<plugin>
						<groupId>org.sonatype.plugins</groupId>
						<artifactId>nexus-staging-maven-plugin</artifactId>
						<version>1.6.7</version>
						<extensions>true</extensions>
						<configuration>
							<serverId>ossrh</serverId>
							<nexusUrl>https://oss.sonatype.org/</nexusUrl>
							<autoReleaseAfterClose>false</autoReleaseAfterClose>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>default-plugin-usage</id>
			<activation>
				<file>
					<missing>.maven_disable_default-plugin-usage</missing>
				</file>
			</activation>
			<build>
				<plugins>
					<!-- Build (tycho target platform) -->
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>target-platform-configuration</artifactId>
					</plugin>
					
					<!-- Build (general) -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-compiler-plugin</artifactId>
					</plugin>

					<!-- Build (tycho) -->
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-source-plugin</artifactId>
					</plugin>
					<plugin>
						<groupId>org.eclipse.tycho.extras</groupId>
						<artifactId>tycho-source-feature-plugin</artifactId>
					</plugin>
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-p2-plugin</artifactId>
					</plugin>
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-maven-plugin</artifactId>
						<extensions>true</extensions>
					</plugin>

					<!-- Cleanup -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-clean-plugin</artifactId>
					</plugin>

					<!-- Tests -->
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-surefire-plugin</artifactId>
					</plugin>

				</plugins>
			</build>
		</profile>
		
		<profile>
			<id>test-suite-configuration</id>
			<activation>
				<file>
					<exists>**/*TestSuite.class</exists>
				</file>	
			</activation>
			<build>
				<pluginManagement>
					<plugins>
						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-surefire-plugin</artifactId>
							<version>${tycho.version}</version>
							<configuration>
								<!-- Test suites explicitly defined as they are sumsuming each other and would lead to redundant test execution -->
								<includes>
									<include>**/*TestSuite.class</include>
								</includes>
							</configuration>
						</plugin>
					</plugins>
				</pluginManagement>
			</build>
		</profile>
					
		<profile>
			<id>compile-xtend</id>
			<activation>
				<file>
					<missing>.maven_disable_compile-xtend</missing>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.eclipse.xtend</groupId>
						<artifactId>xtend-maven-plugin</artifactId>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<profile>
			<id>default-plugin-configurations</id>
			<activation>
				<file>
					<missing>.maven-disable-default-plugin-configurations</missing>
				</file>
			</activation>
			<properties>
				<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
				<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
				<java.version>1.8</java.version>
				<maven.compiler.target>1.8</maven.compiler.target>
				<maven.compiler.source>1.8</maven.compiler.source>
			</properties>
			<build>
				<pluginManagement>
					<plugins>
						<plugin>
							<groupId>org.apache.maven.plugins</groupId>
							<artifactId>maven-compiler-plugin</artifactId>
							<version>3.8.0</version>
							<executions> 
								<execution> 
									<id>compiletests</id> 
									<phase>test-compile</phase> 
									<goals> 
										<goal>testCompile</goal> 
									</goals> 
								</execution> 
							</executions> 
							<configuration>
								<compilerId>eclipse</compilerId>
								<source>${java.version}</source>
								<target>${java.version}</target>
								<optimize>true</optimize>
							</configuration>
							<dependencies>
								<dependency>
									<groupId>org.codehaus.plexus</groupId>
									<artifactId>plexus-compiler-eclipse</artifactId>
									<version>2.8.2</version>
									<scope>runtime</scope>
								</dependency>
							</dependencies>
						</plugin>

						<!-- Creates source versions of bundles -->
						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-source-plugin</artifactId>
							<version>${tycho.version}</version>
							<executions>
								<execution>
									<id>plugin-source</id>
									<goals>
										<goal>plugin-source</goal>
									</goals>
								</execution>
							</executions>
						</plugin>

						<!-- Creates source versions of features -->
						<plugin>
							<groupId>org.eclipse.tycho.extras</groupId>
							<artifactId>tycho-source-feature-plugin</artifactId>
							<version>${tycho.version}</version>
							<executions>
								<execution>
									<id>source-feature</id>
									<phase>package</phase>
									<goals>
										<goal>source-feature</goal>
									</goals>
								</execution>
							</executions>
						</plugin>

						<!-- Correctly handles source features on p2 update site -->
						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-p2-plugin</artifactId>
							<version>${tycho.version}</version>
							<executions>
								<execution>
									<id>attached-p2-metadata</id>
									<phase>package</phase>
									<goals>
										<goal>p2-metadata</goal>
									</goals>
								</execution>
							</executions>
						</plugin>

						<plugin>
							<groupId>org.eclipse.xtend</groupId>
							<artifactId>xtend-maven-plugin</artifactId>
							<version>${xtext.version}</version>
							<executions>
								<execution>
									<phase>generate-sources</phase>
									<goals>
										<goal>compile</goal>
									</goals>
									<configuration>
										<outputDirectory>xtend-gen</outputDirectory>
									</configuration>
								</execution>
							</executions>
						</plugin>

						<plugin>
							<groupId>org.apache.maven.plugins</groupId>
							<artifactId>maven-clean-plugin</artifactId>
							<version>3.0.0</version>
							<executions>
								<execution>
									<id>gen-clean</id>
									<phase>clean</phase>
									<goals>
										<goal>clean</goal>
									</goals>
									<configuration>
										<filesets>
											<fileset>
												<directory>xtend-gen</directory>
											</fileset>
										</filesets>
									</configuration>
								</execution>
							</executions>
						</plugin>

						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-maven-plugin</artifactId>
							<version>${tycho.version}</version>
							<extensions>true</extensions>
						</plugin>

						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-surefire-plugin</artifactId>
							<version>${tycho.version}</version>
							<configuration>
								<includes>
									<include>**/*Test.java</include>
									<include>**/*Tests.java</include>
								</includes>
								<failIfNoTests>false</failIfNoTests>
							</configuration>
						</plugin>

						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>target-platform-configuration</artifactId>
							<version>${tycho.version}</version>
							<configuration>
								<pomDependencies>consider</pomDependencies>
								<environments>
									<environment>
										<os>linux</os>
										<ws>gtk</ws>
										<arch>x86_64</arch>
									</environment>
									<environment>
										<os>win32</os>
										<ws>win32</ws>
										<arch>x86_64</arch>
									</environment>
									<environment>
										<os>macosx</os>
										<ws>cocoa</ws>
										<arch>x86_64</arch>
									</environment>
								</environments>
							</configuration>
						</plugin>

					</plugins>
				</pluginManagement>
			</build>
		</profile>
	</profiles>

</project>
