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

	<parent>
		<groupId>uk.ac.nactem.argo</groupId>
		<artifactId>argo-parent-pom</artifactId>
		<version>0.5</version>
	</parent>

	<artifactId>argo-starter-components</artifactId>
	<version>0.5.1</version>
	<packaging>pom</packaging>

	<name>Argo Starter Components</name>
	<inceptionYear>2017</inceptionYear>
	<url>https://github.com/argo-nactem/argo-starter-components</url>
	<description>Parent POM containing sensible defaults for Argo Component development</description>

	<organization>
		<name>The National Centre for Text Mining (NaCTeM)</name>
		<url>http://nactem.ac.uk</url>
	</organization>
	
	<developers>
		<developer>
			<organization>NaCTeM</organization>
			<organizationUrl>http://nactem.ac.uk</organizationUrl>
		</developer>
	</developers>

	<scm>
		<connection>scm:git:git://github.com/argo-nactem/argo-starter-components</connection>
		<developerConnection>scm:git:git@github.com:argo-nactem/argo-starter-components.git</developerConnection>
		<url>https://github.com/argo-nactem/argo-starter-components</url>
		<tag>HEAD</tag>
	</scm>

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

	<properties>
		<component.id>${project.groupId}.${project.artifactId}</component.id>
	</properties>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
			<resource>
				<directory>desc</directory>
			</resource>
		</resources>
		<plugins>
			<!-- This plugin will automatically generate the UIMA XML component descriptor -->
			<plugin>
				<!-- <groupId>org.apache.uima</groupId> -->
				<artifactId>uimafit-maven-plugin</artifactId>

				<!-- Temporary measure until https://issues.apache.org/jira/browse/UIMA-3346 
					is accepted into uimaFIT -->
				 <groupId>uk.ac.nactem.argo</groupId> 
				<version>2.3.0-NACTEM-1</version> 
				<!-- <groupId>uk.ac.nactem.argo</groupId> -->
				<!-- <version>${uima.version}</version> -->


				<configuration>
					<!-- Adds the type systems required by the component -->
					<typeSystemDescription>BY_NAME</typeSystemDescription>
					<!-- OPTIONAL -->
					<encoding>${project.build.sourceEncoding}</encoding>
				</configuration>
				<executions>
					<execution>
						<id>default</id>
						<phase>process-classes</phase>
						<goals>
							<goal>enhance</goal>
							<goal>generate</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>com.mycila</groupId>
					<artifactId>license-maven-plugin</artifactId>
					<version>3.0</version>
					<configuration>
						<excludes>
							<exclude>src/test/resources/**</exclude>
							<exclude>src/main/resources/**</exclude>
						</excludes>
						<mapping>
							<g4>JAVADOC_STYLE</g4>
						</mapping>
					</configuration>
					<executions>
						<execution>
							<goals>
								<goal>check</goal>
							</goals>
						</execution>
						<execution>
							<id>format-license-headers</id>
							<phase>process-sources</phase>
							<goals>
								<goal>format</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
				<plugin>
					<groupId>org.jasig.maven</groupId>
					<artifactId>maven-notice-plugin</artifactId>
					<version>1.0.6.1</version>
					<inherited>false</inherited>
					<configuration>
						<noticeTemplate>src/license/NOTICE.template</noticeTemplate>
						<generateChildNotices>false</generateChildNotices>
					</configuration>
					<executions>
						<execution>
							<id>generate-notice</id>
							<phase>initialize</phase>
							<goals>
								<goal>generate</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<profiles>
		<profile>
			<id>pear</id>
			<build>
				<plugins>

					<plugin>
						<!-- Copy all of the Maven dependencies into the lib folder of the 
							PEAR file -->
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<version>2.4</version>
						<executions>
							<execution>
								<id>copy-dependencies</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>copy-dependencies</goal>
								</goals>
								<configuration>
									<stripVersion>true</stripVersion>
									<outputDirectory>${project.build.directory}/pearPackaging/lib</outputDirectory>
									<overWriteReleases>true</overWriteReleases>
									<overWriteSnapshots>true</overWriteSnapshots>
									<includeScope>runtime</includeScope>
								</configuration>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.codehaus.gmaven</groupId>
						<artifactId>groovy-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-uima-descriptor</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>execute</goal>
								</goals>
								<configuration>
									<source>
										def uimaClass = project.properties['uima.component.class'];

										if (!uimaClass) {
											fail("Missing Maven property 'uima.component.class'");
										}

										def descriptorPath = uimaClass.replaceAll('\\.','/') + '.xml';

										def sourceFile = new File(project.build.outputDirectory + '/' + descriptorPath);

										if (!sourceFile.exists()) {
											fail("Cannot locate UIMA XML descriptor '" + sourceFile.getAbsolutePath() + "'. Is the Maven property 'uima.component.class' (" + uimaClass + ") correct?")
										}

										def targetFile = new File(project.build.directory + '/pearPackaging/desc/' + descriptorPath);

										targetFile.getParentFile().mkdirs();
										//targetFile &lt;&lt; sourceFile.text;
										targetFile.newWriter().withWriter { 
  											w -> w &lt;&lt; sourceFile.text
										}

										project.properties['uima.pear.descriptor'] = 'desc/' + descriptorPath;
									</source>
								</configuration>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.uima</groupId>
						<artifactId>PearPackagingMavenPlugin</artifactId>
						<version>${uima.version}</version>
						<extensions>true</extensions>
						<configuration>
							<!-- This value should give the path of the component's UIMA XML descriptor 
								file -->
							<mainComponentDesc>${uima.pear.descriptor}</mainComponentDesc>

							<!-- This value should be a unique identifier for this component. 
								It is recommended that this be the same as the fully qualified name of the 
								component's Java class -->
							<componentId>${uima.component.class}</componentId>
						</configuration>
						<executions>
							<execution>
								<phase>package</phase>
								<configuration>
								</configuration>
								<goals>
									<goal>package</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>

		</profile>

		<profile>
			<id>create-license-list</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<version>1.5</version>
						<configuration>
							<useMissingFile>true</useMissingFile>
						</configuration>
						<executions>
							<execution>
								<id>create-license-list</id>
								<goals>
									<goal>aggregate-add-third-party</goal>
								</goals>
								<phase>generate-resources</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<dependencies>
		<dependency>
			<groupId>org.apache.uima</groupId>
			<artifactId>uimaj-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.uima</groupId>
			<artifactId>uimafit-core</artifactId>
		</dependency>
	</dependencies>

</project>