Search code examples
javamavenintellij-ideaantmaven-antrun-plugin

SCP task not found (ant-run through maven)


I've been trying to deploy a packaged jar onto some raspberry pi connected to the lan with a static ip of 192.168.0.101 through maven. Here is the important part of my pom.xml :

<dependencies>
... SNIP ...
        <!-- SSH & FTP -->
    <dependency>
        <groupId>commons-net</groupId>
        <artifactId>commons-net</artifactId>
        <version>3.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant-commons-net</artifactId>
        <version>1.10.0</version>
    </dependency>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.54</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant-jsch</artifactId>
        <version>1.10.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>

            <executions>
                <execution>
                    <id>scp-to-remote</id>
                    <phase>install</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>

                            <!-- Upload jar via ftp to /home/pi/server -->
                            <scp localFile="${project.basedir}/target/button-masher-1.0.jar"
                                 remoteToFile="${rserver.user}@${rserver.ip}:${rserver.script.server.dir}" verbose="true"
                                 password="${rserver.pass}" trust="true">
                            </scp>

                            <!-- calls deploy script -->
                            <sshexec host="${rserver.ip}" trust="yes"
                                     username="${rserver.user}" password="${rserver.pass}"
                                     command="sh ${rserver.script.server.startup}" />

                            <taskdef name="scp"
                                     classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp"
                                     classpathref="maven.plugin.classpath" />

                            <taskdef name="sshexec"
                                     classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
                                     classpathref="maven.plugin.classpath" />

                            <taskdef name="ftp"
                                     classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
                                     classpathref="maven.plugin.classpath" />

                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Here is a picture showing that on %ANT_HOME%/lib jsch.jar and jsch-ant.jar are present (jsch is latest version): ant_home/lib

Whenever I run maven install (-Dmaven.test.skip=true) I get this error: error

But all ant's optional jars/components that are needed are present. The IDE i use is IntelliJ IDEA Ultimate. I use a non-bundled (normally installed) maven version from the windows cmd in order to execute the commands.


Solution

  • Fixed by changing

    maven.plugin.classpath

    to

    maven.compile.classpath