<?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">
    <parent>
        <artifactId>pi4j-plugin</artifactId>
        <groupId>com.pi4j</groupId>
        <version>2.3.0</version>
        <relativePath>../pi4j-plugin/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <!-- MAVEN ARTIFACT INFORMATION -->
    <artifactId>pi4j-plugin-raspberrypi</artifactId>
    <name>Pi4J :: PLUGIN   :: RaspberryPi Platform &amp; Providers</name>
    <description>Pi4J Library Plugin for the RaspberryPi Platform &amp; I/O Providers</description>
    <packaging>jar</packaging>

    <!-- STANDARD BUILD INSTRUCTIONS -->
    <build>
        <plugins>
            <!-- OPTIONALLY DEPLOY THE FINAL JAR TO THE RASPBERRY PI -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>

                    <!-- copy the compiled JAR file to the Raspberry Pi platform platform -->
                    <execution>
                        <id>transfer-compiled-pi4j-jar</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <taskdef resource="net/sf/antcontrib/antcontrib.properties"
                                         classpathref="maven.plugin.classpath" />
                                <if>
                                    <equals arg1="${pi4j.dev.transfer}" arg2="true" />
                                    <then>
                                        <!-- ensure the target directory exists on the Raspberry Pi -->
                                        <sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}" username="${pi4j.dev.user}"
                                                 password="${pi4j.dev.password}" trust="true" failonerror="false"
                                                 verbose="false" command="mkdir --parents ${pi4j.dev.directory}" />

                                        <!-- copy the JAR file to the Raspberry Pi -->
                                        <scp file="${project.build.directory}/${project.build.finalName}.jar"
                                             todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
                                             port="${pi4j.dev.port}" trust="true" verbose="false" failonerror="true">
                                        </scp>
                                    </then>
                                </if>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
