<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>au.org.ecoinformatics</groupId>
	<artifactId>eml-api</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>jar</packaging>
	<name>EML API</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>1.6</java.version>
		<hamcrest.version>1.3</hamcrest.version>
		<mockito.version>1.9.5</mockito.version>
		<slf4j.version>1.7.7</slf4j.version>
		<jaxb.version>2.2.11</jaxb.version>
		<jaxb.output.dir>${basedir}/src/main/jaxb/</jaxb.output.dir>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.glassfish.jaxb</groupId>
			<artifactId>jaxb-runtime</artifactId>
			<version>${jaxb.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<version>${mockito.version}</version>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.hamcrest</groupId>
					<artifactId>hamcrest-core</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-library</artifactId>
			<version>${hamcrest.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>jaxb</id>
			<!-- regenerates the JAXB classes -->
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>copyXjb</id>
								<phase>generate-sources</phase>
								<configuration>
									<tasks>
										<!-- The JAXB generation required/expects the .xjb to live in the same directory as the XSDs. I'm not happy checking 
											it in there because that directory should only contain the XSDs from the archive. -->
										<copy file="${basedir}/xsd/custom-bindings.xjb" tofile="${basedir}/xsd/eml-2.1.1/custom-bindings.xjb" />
									</tasks>
								</configuration>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
							<execution>
								<id>removeCopiedXjb</id>
								<phase>process-sources</phase>
								<configuration>
									<tasks>
										<delete file="${basedir}/xsd/eml-2.1.1/custom-bindings.xjb" />
									</tasks>
								</configuration>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>jaxb2-maven-plugin</artifactId>
						<version>1.6</version>
						<dependencies>
							<dependency>
								<groupId>org.jvnet.jaxb2_commons</groupId>
								<artifactId>jaxb2-fluent-api</artifactId>
								<version>3.0</version>
								<exclusions>
									<exclusion>
										<groupId>com.sun.xml</groupId>
										<artifactId>jaxb-xjc</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
						<configuration>
							<arguments>-Xfluent-api</arguments>
							<extension>true</extension>
							<outputDirectory>${jaxb.output.dir}</outputDirectory>
						</configuration>
						<executions>
							<execution>
								<id>sysmeta</id>
								<goals>
									<goal>xjc</goal>
								</goals>
								<configuration>
									<packageName>au.org.ecoinformatics.eml.jaxb.sysmeta</packageName>
									<schemaDirectory>${basedir}/xsd/</schemaDirectory>
									<schemaFiles>dataoneTypes.xsd</schemaFiles>
									<clearOutputDir>true</clearOutputDir>
								</configuration>
							</execution>
							<execution>
								<id>eml</id>
								<goals>
									<goal>xjc</goal>
								</goals>
								<configuration>
									<packageName>au.org.ecoinformatics.eml.jaxb.eml</packageName>
									<bindingDirectory>${basedir}/xsd/eml-2.1.1/</bindingDirectory>
									<bindingFiles>custom-bindings.xjb</bindingFiles>
									<schemaDirectory>${basedir}/xsd/eml-2.1.1/</schemaDirectory>
									<schemaFiles>eml.xsd</schemaFiles>
									<clearOutputDir>false</clearOutputDir>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<!-- apply a patch to the generated JAXB classes to make them less painful to use -->
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-patch-plugin</artifactId>
						<version>1.1.1</version>
						<configuration>
							<patchFile>${basedir}/src/main/patches/au/org/ecoinformatics/eml/jaxb-generated-classes.patch</patchFile>
							<targetDirectory>${basedir}</targetDirectory>
						</configuration>
						<executions>
							<execution>
								<id>patch</id>
								<phase>process-sources</phase>
								<goals>
									<goal>apply</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.2.1</version>
				<executions>
					<execution>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>${java.version}</source>
					<target>${java.version}</target>
					<compilerArgument>-Xlint:all</compilerArgument>
					<showWarnings>true</showWarnings>
					<showDeprecation>true</showDeprecation>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.17</version>
				<configuration>
					<redirectTestOutputToFile>true</redirectTestOutputToFile>
					<includes>
						<include>**/*.class</include>
					</includes>
					<excludes>
						<!-- Exclude all of maven-failsafe-plugin's includes -->
						<exclude>**/IT*.java</exclude>
						<exclude>**/*IT.java</exclude>
						<exclude>**/*ITCase.java</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.9.1</version>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${jaxb.output.dir}</source>
								<source>${basedir}/src/main/patches/</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>