<?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>
	<artifactId>wpilibJavaJNI</artifactId>
	<groupId>edu.wpi.first.wpilibj</groupId>
	<version>0.1.0-SNAPSHOT</version>
	<packaging>pom</packaging>
	<dependencies>
		<dependency>
			<groupId>edu.wpi.first.wpilib.cmake</groupId>
			<artifactId>cpp-root</artifactId>
			<version>1.0.0</version>
			<type>zip</type>
		</dependency>
		<dependency>
			<groupId>edu.wpi.first.wpilibj</groupId>
			<artifactId>wpilibJavaDevices</artifactId>
			<version>0.1.0-SNAPSHOT</version>
			<type>jar</type>
		</dependency>
	</dependencies>
	<repositories>

  </repositories>
	<pluginRepositories>

  </pluginRepositories>
	<properties>
		<embeddedJDKHome>${user.home}${file.separator}jdk-linux-arm-vfp-sflt${file.separator}jdk1.7.0_45</embeddedJDKHome>
		<embeddedJDKIncludePath>${embeddedJDKHome}${file.separator}include</embeddedJDKIncludePath>
	</properties>
	<profiles>
		<profile>
			<id>unix-properties</id>
			<properties>
				<cmakeGenerator>Unix Makefiles</cmakeGenerator>
			</properties>
			<activation>
				<os>
					<family>unix</family>
				</os>
			</activation>
		</profile>
		<profile>
			<id>MAC-properties</id>
			<properties>
				<cmakeGenerator>Unix Makefiles</cmakeGenerator>
			</properties>
			<activation>
				<os>
					<family>mac</family>
				</os>
			</activation>
		</profile>
		<profile>
			<id>windows-properties</id>
			<properties>
				<cmakeGenerator>MSYS Makefiles</cmakeGenerator>
			</properties>
			<activation>
				<os>
					<family>windows</family>
				</os>
			</activation>
		</profile>
	</profiles>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<version>1.3.1</version>
				<executions>
					<execution>
						<id>enforce-property</id>
						<goals>
							<goal>enforce</goal>
						</goals>
						<configuration>
							<rules>
								<requireFilesExist>
									<files>
										<file>${embeddedJDKIncludePath}</file>
									</files>
									<message>A copy of the 'Linux ARM v6/v7 Soft Float ABI' JDK must be extracted to '${embeddedJDKHome}' and
the folder '${embeddedJDKIncludePath}' must exist to build this module. You must use Java 7 u45. This JDK may be downloaded from
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u45-oth-JPR. To override
this default location, specify a value for the 'embeddedJDKHome' property at the command line, like 'mvn -DembeddedJDKHome=path/to/jdk'</message>
								</requireFilesExist>
							</rules>
							<fail>true</fail>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>native-maven-plugin</artifactId>
				<version>1.0-alpha-7</version>
				<extensions>true</extensions>
				<configuration>
					<javahOS>linux</javahOS>
					<jdkIncludePath>${embeddedJDKIncludePath}</jdkIncludePath>
				</configuration>
				<executions>
					<execution>
						<id>javah</id>
						<phase>generate-sources</phase>
						<configuration>
							<!-- trigger javah execution -->
							<javahClassNames>
								<javahClassName>edu.wpi.first.wpilibj.can.CANJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.HALUtil</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.JNIWrapper</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.AccelerometerJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.AnalogJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.CounterJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.DIOJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.EncoderJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.I2CJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.InterruptJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.PWMJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.RelayJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.SPIJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.SolenoidJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.CompressorJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.PDPJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.PowerJNI</javahClassName>
								<javahClassName>edu.wpi.first.wpilibj.hal.SerialPortJNI</javahClassName>
							</javahClassNames>
							<!-- enable additional javah interface in dependencies list -->
							<!-- javahSearchJNIFromDependencies>true</javahSearchJNIFromDependencies -->
							<!--
            			| Add jdk include directories to system include path
            			| Override ${jkdIncludePath} If your jdk does not conform to Sun JDK layout
            			-->
							<javahOS>linux</javahOS>
							<javahOutputDirectory>${project.build.directory}/include</javahOutputDirectory>
							<javahProvider>default</javahProvider>
							<javahVerbose>true</javahVerbose>
						</configuration>
						<goals>
							<goal>javah</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- TODO: currently we just call cmake which uses relative include paths. Use maven inflation? -->
			<plugin>
				<groupId>com.googlecode.cmake-maven-project</groupId>
				<artifactId>cmake-maven-plugin</artifactId>
				<version>2.8.11-b4</version>
				<executions>
					<execution>
						<id>cmake</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<options>
								<option>-DCMAKE_TOOLCHAIN_FILE=../../arm-toolchain.cmake</option>
								<option>-DCMAKE_INSTALL_PREFIX=../../</option>
								<option>-DembeddedJDKHome=${embeddedJDKHome}</option>
							</options>
							<environmentVariables>
								<VERBOSE>1</VERBOSE>
							</environmentVariables>
						</configuration>
					</execution>
					<execution>
						<id>cmake2</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>compile</goal>
						</goals>
						<configuration>
							<target>install</target>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<sourcePath>.</sourcePath>
					<targetPath>${project.build.directory}/cmake</targetPath>
					<projectDirectory>${project.build.directory}/cmake</projectDirectory>
					<generator>${cmakeGenerator}</generator>
					<buildType>release</buildType>
				</configuration>
			</plugin>
			<!-- <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.8</version>
				<executions>
					 COMMENT ME: Fetch the dependencies needed to build the cpp.zip file.
					 <execution>
						<id>fetch-cpp-zip-dependencies</id>
						<phase>process-sources</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>edu.wpi.first.wpilib.cmake</groupId>
									<artifactId>cpp-root</artifactId>
									<version>1.0.0</version>
									<type>zip</type>
									<destFileName>cpp-root.zip</destFileName>
								</artifactItem>
							</artifactItems>
							<outputDirectory>${project.build.directory}</outputDirectory>
							<overWriteReleases>false</overWriteReleases>
							<overWriteSnapshots>true</overWriteSnapshots>
							<prependGroupId>false</prependGroupId>
						</configuration>
					</execution>
				</executions>
			</plugin> -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<id>extract-cpp-zip</id>
						<goals>
							<goal>run</goal>
						</goals>
						<phase>process-sources</phase>
						<configuration>
							<target>
								<taskdef resource="net/sf/antcontrib/antcontrib.properties"
                  					classpathref="maven.plugin.classpath" />

								<property name="mvn.cpp-root.zip.path" value="${edu.wpi.first.wpilib.cmake:cpp-root:zip}"/>

								<available file="${mvn.cpp-root.zip.path}" type="file" property="mvn.cpp-root.zip.isfile" />

								<if>
									<isset property="mvn.cpp-root.zip.isfile" />
									<then>
										<unzip src="${mvn.cpp-root.zip.path}" dest="${project.build.directory}" />
									</then>
									<else>
										<copy todir="${project.build.directory}" >
									        <fileset dir="${mvn.cpp-root.zip.path}" />
									 	</copy>
									</else>
								</if>
							</target>
						</configuration>
					</execution>

					<!-- Set time stamp and version properties. -->
					<execution>
						<id>set-version-info</id>
						<goals>
							<goal>run</goal>
						</goals>
						<phase>process-sources</phase>
						<configuration>
							<target>
								<tstamp>
									<format property="timestamp" pattern="yyyy/MM/dd HH:mm:ss z"/>
								</tstamp>
								<tstamp>
									<format property="version-info" pattern="yyyy.MM"/>
								</tstamp>
								<property name="version" value="${version-info}.${build-number}"/>
							</target>
							<exportAntProperties>true</exportAntProperties>
						</configuration>
					</execution>
				</executions>
				<dependencies>
					<dependency>
			            <groupId>ant-contrib</groupId>
			            <artifactId>ant-contrib</artifactId>
			            <version>1.0b3</version>
			            <exclusions>
					    	<exclusion>
						        <groupId>ant</groupId>
						        <artifactId>ant</artifactId>
					      	</exclusion>
					    </exclusions>
			        </dependency>
				</dependencies>
			</plugin>
					      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
        <execution>
						<id>zip-cpp-includes</id>
						<phase>compile</phase>
						<goals>
							<goal>attach-artifact</goal>
						</goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/libwpilibJavaJNI.so</file>
                  <type>so</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
		</plugins>
	</build>
</project>
