<?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.mdsd</groupId>
	<artifactId>eclipse-parent</artifactId>
	<version>0.8.2</version>
	<name>${project.artifactId}</name>
	<description>A common parent POM for all Eclipse builds of MDSD.tools.</description>
	<url>http://mdsd.tools</url>
	<packaging>pom</packaging>

	<licenses>
		<license>
			<name>The Apache License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
		</license>
	</licenses>

	<developers>
		<developer>
			<name>Nicolas Boltz</name>
			<email>boltz@kit.edu</email>
			<organization>Karlsruhe Institute of Technology (KIT), Germany</organization>
			<organizationUrl>http://kit.edu</organizationUrl>
		</developer>
		<developer>
			<name>Larissa Schmid</name>
			<email>schmid@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/mdsd-tools/maven-build-parents.git</connection>
		<developerConnection>scm:git:ssh://github.com/mdsd-tools/maven-build-parents.git</developerConnection>
		<url>http://github.com/mdsd-tools/maven-build-parents/tree/master</url>
	</scm>

	<properties>
		<tycho.version>2.7.0</tycho.version>
		<tycho-javadoc.version>2.2.0</tycho-javadoc.version>
		<org.palladiosimulator.maven.tychotprefresh.version>0.2.6</org.palladiosimulator.maven.tychotprefresh.version>
		<javadoc.args>
			-tag "generated:a:Generated class or method."
			-tag "model:a:EMF model class or method."
			-tag "ordered:a:Ordered collection."
			-tag 'noimplement:a:Restriction:'
			-tag 'noextend:a:Restriction:'
			-tag 'noreference:a:Restriction:'
			-tag 'noinstantiate:a:Restriction:'
			-tag 'nooverride:a:Restriction:'
			-tag 'category:a:Category:'
			-link ${java.api.doc}
			-link https://help.eclipse.org/2021-12/topic/org.eclipse.platform.doc.isv/reference/api
			-link https://download.eclipse.org/modeling/emf/emf/javadoc/2.11/
			-link https://download.eclipse.org/modeling/emft/mwe/javadoc/2.9/
		</javadoc.args>
		<!-- The property is meant to be overridden but still has to contain valid content, so we just repeat valid content. -->
		<javadoc.additional.args>
			-link ${java.api.doc}
		</javadoc.additional.args>
		<updatesite.aggregator.smtpHost>smtp.ira.uka.de</updatesite.aggregator.smtpHost>
	</properties>
	
	<build>
		<plugins>
			<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>nexus-staging-maven-plugin</artifactId>
				<version>1.6.13</version>
				<extensions>true</extensions>
				<configuration>
					<serverId>ossrh</serverId>
					<nexusUrl>https://oss.sonatype.org/</nexusUrl>
					<autoReleaseAfterClose>true</autoReleaseAfterClose>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>

		<!-- Build configuration of parent POM itself -->
		<profile>
			<id>local-build-deployable</id>
			<!-- activate this profile explicitly by adding -Plocal-build-deployable to the maven command -->
			<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>
						<configuration>
							<gpgArguments>
								<arg>--pinentry-mode</arg>
								<arg>loopback</arg>
							</gpgArguments>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Profiles to be inherited -->

		<profile>
			<id>nightly</id>
			<activation>
				<property>
					<name>!release</name>
				</property>
			</activation>
			<properties>
				<org.palladiosimulator.maven.tychotprefresh.filter.0>nightly</org.palladiosimulator.maven.tychotprefresh.filter.0>
				<updatesite.aggregator.filename>target/classes/nightly.aggr</updatesite.aggregator.filename>
			</properties>

			<pluginRepositories>
				<pluginRepository>
					<id>sonatype-snapshots</id>
					<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
					<releases>
						<enabled>false</enabled>
					</releases>
					<snapshots>
						<updatePolicy>always</updatePolicy>
					</snapshots>
				 </pluginRepository>
				 <pluginRepository>
					<id>tycho-snapshots</id>
					<url>https://repo.eclipse.org/content/repositories/tycho-snapshots/</url>
					<releases>
						<enabled>false</enabled>
					</releases>
					<snapshots>
						<updatePolicy>always</updatePolicy>
					</snapshots>
				 </pluginRepository>
			 </pluginRepositories>
		</profile>

		<profile>
			<id>release</id>
			<activation>
				<property>
					<name>release</name>
				</property>
			</activation>
			<properties>
				<org.palladiosimulator.maven.tychotprefresh.filter.0>release</org.palladiosimulator.maven.tychotprefresh.filter.0>
				<updatesite.aggregator.filename>target/classes/release.aggr</updatesite.aggregator.filename>
			</properties>
		</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>
					<plugin>
						<groupId>org.palladiosimulator</groupId>
						<artifactId>tycho-tp-refresh-maven-plugin</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</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.jacoco</groupId>
						<artifactId>jacoco-maven-plugin</artifactId>
					</plugin>
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-surefire-plugin</artifactId>
					</plugin>

				</plugins>
			</build>
		</profile>

		<!-- JavaDoc for update site projects -->
		<profile>
			<id>tycho-javadoc-for-updatesite</id>
			<activation>
				<file>
					<exists>category.xml</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.palladiosimulator</groupId>
						<artifactId>tycho-document-bundle-plugin</artifactId>
						<version>${tycho-javadoc.version}</version>
						<executions>
							<execution>
								<id>eclipse-javadoc</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>javadoc</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.directory}/repository/javadoc</outputDirectory>
									<exportOnly>false</exportOnly>
									<skipTocGen>true</skipTocGen>
									<javadocOptions>
										<additionalArguments>
											<additionalArgument>${javadoc.args}</additionalArgument>
											<additionalArgument>${javadoc.additional.args}</additionalArgument>
										</additionalArguments>
									</javadocOptions>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>tycho-javadoc-for-bundle</id>
			<activation>
				<file>
					<exists>META-INF/MANIFEST.MF</exists>
				</file>
				<property>
					<name>generateJavaDocPerBundle</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.palladiosimulator</groupId>
						<artifactId>tycho-document-bundle-plugin</artifactId>
						<version>${tycho-javadoc.version}</version>
						<executions>
							<execution>
								<id>artifact-javadoc</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>javadoc</goal>
								</goals>
								<configuration>
									<exportOnly>false</exportOnly>
									<skipTocGen>true</skipTocGen>
									<outputDirectory>${project.build.directory}/javadoc</outputDirectory>
									<considerSourcesOfCurrentProject>true</considerSourcesOfCurrentProject>
									<considerSourcesOfDependencies>false</considerSourcesOfDependencies>
									<javadocOptions>
										<additionalArguments>
											<additionalArgument>${javadoc.args}</additionalArgument>
											<additionalArgument>${javadoc.additional.args}</additionalArgument>
										</additionalArguments>
									</javadocOptions>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>3.2.0</version>
						<executions>
							<execution>
								<id>artifact-javadoc-package</id>
								<goals>
									<goal>jar</goal>
								</goals>
								<configuration>
									<archive>
										<addMavenDescriptor>false</addMavenDescriptor>
									</archive>
									<classesDirectory>${project.build.directory}/javadoc</classesDirectory>
									<classifier>javadoc</classifier>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</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>${project.build.sourceEncoding}</project.reporting.outputEncoding>
				<java.version>17</java.version>
				<java.api.doc>https://docs.oracle.com/en/java/javase/17/docs/api/</java.api.doc>
				<maven.compiler.target>${java.version}</maven.compiler.target>
				<maven.compiler.source>${java.version}</maven.compiler.source>
			</properties>
			<build>
				<pluginManagement>
					<plugins>
						<plugin>
							<groupId>org.apache.maven.plugins</groupId>
							<artifactId>maven-compiler-plugin</artifactId>
							<version>3.8.1</version>
						</plugin>

						<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>
								<execution>
									<id>feature-source</id>
									<goals>
										<goal>feature-source</goal>
									</goals>
								</execution>
							</executions>
						</plugin>

						<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>2.26.0</version>
							<executions>
								<execution>
									<goals>
										<goal>compile</goal>
									</goals>
									<configuration>
										<outputDirectory>xtend-gen</outputDirectory>
										<javaSourceVersion>11</javaSourceVersion>
									</configuration>
								</execution>
							</executions>
						</plugin>

						<plugin>
							<groupId>org.apache.maven.plugins</groupId>
							<artifactId>maven-clean-plugin</artifactId>
							<version>3.1.0</version>
							<configuration>
								<excludeDefaultDirectories>true</excludeDefaultDirectories>
								<filesets>
									<fileset>
										<directory>${project.basedir}</directory>
										<includes>
											<include>target/**</include>
											<include>xtend-gen/**</include>
											<include>emfparsley-gen/**</include>
										</includes>
										<excludes>
											<exclude>*/.gitkeep</exclude>
										</excludes>
									</fileset>
								</filesets>
							</configuration>
						</plugin>

						<plugin>
							<groupId>org.eclipse.tycho</groupId>
							<artifactId>tycho-maven-plugin</artifactId>
							<version>${tycho.version}</version>
							<extensions>true</extensions>
						</plugin>

						<plugin>
							<groupId>org.jacoco</groupId>
							<artifactId>jacoco-maven-plugin</artifactId>
							<version>0.8.7</version>
							<executions>
								<execution>
									<id>jacoco-prepare</id>
									<phase>generate-test-sources</phase>
									<goals>
										<goal>prepare-agent</goal>
									</goals>
								</execution>
							</executions>
						</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>
					</plugins>
				</pluginManagement>
			</build>
		</profile>

		<profile>
			<id>execute-generate-workflow</id>
			<activation>
				<file>
					<exists>workflow/generate.mwe2</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.6.0</version>
						<executions>
							<execution>
								<id>ExecuteMWE2LauncherForGenerate</id>
								<phase>generate-sources</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
									<arguments>
										<argument>/${project.basedir}/workflow/generate.mwe2</argument>
										<argument>-p</argument>
										<argument>workspaceRoot=/${maven.multiModuleProjectDirectory}</argument>
									</arguments>
									<classpathScope>compile</classpathScope>
									<includePluginDependencies>true</includePluginDependencies>
									<cleanupDaemonThreads>false</cleanupDaemonThreads> <!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=475098#c3 -->
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>execute-clean-workflow</id>
			<activation>
				<file>
					<exists>workflow/clean.mwe2</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.6.0</version>
						<executions>
							<execution>
								<id>ExecuteMWE2LauncherForClean</id>
								<phase>clean</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
									<arguments>
										<argument>/${project.basedir}/workflow/clean.mwe2</argument>
										<argument>-p</argument>
										<argument>workspaceRoot=/${maven.multiModuleProjectDirectory}</argument>
									</arguments>
									<classpathScope>compile</classpathScope>
									<includePluginDependencies>true</includePluginDependencies>
									<cleanupDaemonThreads>false
									</cleanupDaemonThreads> <!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=475098#c3 -->
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- OS specific properties -->
		<profile>
			<id>win32-amd64</id>
			<activation>
				<os>
					<arch>amd64</arch>
					<family>windows</family>
				</os>
			</activation>
			<properties>
				<target.platform.os>win32</target.platform.os>
				<target.platform.ws>win32</target.platform.ws>
				<target.platform.arch>x86_64</target.platform.arch>
			</properties>
		</profile>
		<profile>
			<id>linux-amd64</id>
			<activation>
				<os>
					<arch>amd64</arch>
					<family>unix</family>
					<name>linux</name>
				</os>
			</activation>
			<properties>
				<target.platform.os>linux</target.platform.os>
				<target.platform.ws>gtk</target.platform.ws>
				<target.platform.arch>x86_64</target.platform.arch>
			</properties>
		</profile>
		<profile>
			<id>cocoa-macosx-x86_64</id>
			<activation>
				<os>
					<arch>x86_64</arch>
					<family>unix</family>
					<name>mac os x</name>
				</os>
			</activation>
			<properties>
				<target.platform.os>macosx</target.platform.os>
				<target.platform.ws>cocoa</target.platform.ws>
				<target.platform.arch>x86_64</target.platform.arch>
			</properties>
		</profile>

		<profile>
			<id>updatesite-maven-aggregator</id>
			<activation>
				<file>
					<exists>updatesite-aggr</exists>
				</file>
			</activation>
			<build>
				<resources>
					<resource>
						<directory>updatesite-aggr</directory>
						<filtering>true</filtering>
					</resource>
				</resources>
				<plugins>
					<plugin>
						<groupId>org.eclipse.tycho.extras</groupId>
						<artifactId>tycho-eclipserun-plugin</artifactId>
						<version>${tycho.version}</version>
						<executions>
							<execution>
								<goals>
									<goal>eclipse-run</goal>
								</goals>
								<phase>package</phase>
							</execution>
						</executions>
						<configuration>
							<applicationsArgs>
								<args>-data</args>
								<args>${project.build.directory}/eclipserun-work/</args>
								<args>-application</args>
								<args>org.eclipse.cbi.p2repo.cli.headless</args>
								<args>aggregate</args>
								<args>--buildModel</args>
								<args>${updatesite.aggregator.filename}</args>^
								<args>--smtpHost</args>
								<args>${updatesite.aggregator.smtpHost}</args>
								<args>--action</args>
								<args>BUILD</args>
							</applicationsArgs>
							<dependencies>
								<dependency>
									<artifactId>org.eclipse.cbi.p2repo.aggregator.engine.feature</artifactId>
									<type>eclipse-feature</type>
								</dependency>
								<dependency>
									<artifactId>org.eclipse.equinox.core.feature</artifactId>
									<type>eclipse-feature</type>
								</dependency>
								<dependency>
									<artifactId>org.eclipse.equinox.p2.core.feature</artifactId>
									<type>eclipse-feature</type>
								</dependency>
								<dependency>
									<artifactId>org.eclipse.core.net</artifactId>
									<type>eclipse-plugin</type>
								</dependency>
							</dependencies>
							<repositories>
								<repository>
									<id>cbi-aggregator</id>
									<layout>p2</layout>
									<url>http://download.eclipse.org/cbi/updates/aggregator/headless/4.20/</url>
								</repository>
								<repository>
									<id>Eclipse 2021-12</id>
									<layout>p2</layout>
									<url>http://download.eclipse.org/releases/2021-12</url>
								</repository>
							</repositories>
							<work>${project.build.directory}/eclipserun-work</work>
							<executionEnvironment>JavaSE-17</executionEnvironment>
						</configuration>
					</plugin>
					<plugin>
						<groupId>tools.mdsd</groupId>
						<artifactId>pom-enhancer-maven-plugin</artifactId>
						<version>0.1.1</version>
						<executions>
							<execution>
								<goals>
									<goal>enhance-pom</goal>
								</goals>
								<phase>package</phase>
							</execution>
						</executions>
						<configuration>
							<scanDir>
								<fileSet>
									<directory>${project.build.directory}/m2/final/</directory>
									<includes>
										<include>**/*.pom</include>
									</includes>
								</fileSet>
							</scanDir>
							<pomTemplate>${maven.multiModuleProjectDirectory}/pom.xml</pomTemplate>
							<requiredFields>description,scm,licenses,name,url,developers</requiredFields>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>enable-dagger</id>
			<activation>
				<file>
					<exists>.enable_dagger_annotation_processing</exists>
				</file>
			</activation>

			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-compiler-plugin</artifactId>
						<version>3.8.1</version>
						<executions>
							<execution>
								<id>process-dagger-annotations</id>
								<goals>
									<goal>compile</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<annotationProcessorPaths>
										<annotationProcessorPath>
											<groupId>com.google.dagger</groupId>
											<artifactId>dagger-compiler</artifactId>
											<version>2.31</version>
										</annotationProcessorPath>
									</annotationProcessorPaths>
									<proc>only</proc>
									<generatedSourcesDirectory>${project.basedir}/src-gen/</generatedSourcesDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-clean-plugin</artifactId>
						<version>3.1.0</version>
						<executions>
							<execution>
								<id>clean-src-gen</id>
								<phase>clean</phase>
								<goals>
									<goal>clean</goal>
								</goals>
								<configuration>
									<excludeDefaultDirectories>true</excludeDefaultDirectories>
									<filesets>
										<fileset>
											<directory>${project.basedir}</directory>
											<includes>
												<include>src-gen/**</include>
											</includes>
											<excludes>
												<exclude>*/.gitkeep</exclude>
											</excludes>
										</fileset>
									</filesets>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

	</profiles>

</project>
