Developers, Developers, Developers! Maksim Sorokin IT Blog

26Aug/10Off

Copy Files with SCP Using Maven

You can use Maven AntRun Plugin and Ant SCP task in order to transfer files with SCP:

...
  <build>
    ...
    <plugins>
    ...
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <configuration>
          <tasks>
            <scp todir="${scp.user}:${scp.password}@${scp.host}:/${scp.dirCopyTo}" trust="true" failonerror="false">
              <fileset dir="${bundle.dir}" />
            </scp>
          </tasks>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.6.5</version>
          </dependency>
          <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.42</version>
          </dependency>
        </dependencies>
      </plugin>
...

Alternatively, you can use Ant sshexec command in order to do additional stuff through SSH, like create or remove folders.

Tagged as: , , , Comments Off
Comments (2) Trackbacks (0)
  1. I am looking to SCP files and directories just like you have above. I have setup like you outlined above but it appears the copy never finishes.
    I don’t get the “Build Successful message any longer with this task added.
    Any suggestions??

  2. What do you mean “copy never finishes”? Can you copy maven output?
    Do you see any connection attempts from the server?


Leave a comment


Trackbacks are disabled.