0

I am trying to transfer a bunch of .txt from a remote server to my local machine as part of my maven build. I am using the maven-ant-run plugin here. I've noticed that I can only transfer one file as opposed to using a fileSet and the number of .txt files on the remote server does increase/decrease dynamincally so there are no set amount of .txt files so I simply cant hardcode it. Any suggestions?

So I've tried giving wagon plugin a go. This is my pom config for it:

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>wagon-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>execute-test-commands</id>
                    <phase>process-test-class</phase>
                    <goals>
                        <goal>download</goal>
                    </goals>
                    <configuration>
                        <url>scp://${scp.user}:${scp.password}@${scp.host}</url>
                        <fromDir>testOutput</fromDir>
                        <includes>*.txt</includes>
                        <toDir>src/test/resources/unit</toDir>
                    </configuration>
                </execution>
            </executions>
        </plugin>

And this is my output:

[INFO] Downloading scp://*.*.net/testOutput/JOSE.txt to 

C:\Users\Hello\Desktop\AANewMaven\Access\src\test\resources\lua\kong\plugins\JOSE.txt ...
Executing command: scp -p -f "/testOutput/JOSE.txt"
Remote file permissions: 0664
Remote file size: 399
Remote filename: JOSE.txt
attempting to create parent directories for destination: JOSE.txt
Downloading: testOutput/JOSE.txt from scp://*.*.net

#

(I've place * for confidential reasons)

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
lualover2017
  • 207
  • 1
  • 6
  • 16
  • `ant` also has an `` task where you could issue an OS command to copy that files. – Timothy Truckle Feb 10 '17 at 10:56
  • Could you elaborate more? Thanks – lualover2017 Feb 10 '17 at 10:58
  • *"Could you elaborate more?"* on the ant task? https://ant.apache.org/manual/Tasks/exec.html or how to copy files from remote wia OS? – Timothy Truckle Feb 10 '17 at 11:02
  • On how to copy the files remotely. Thank you – lualover2017 Feb 10 '17 at 11:14
  • *"On how to copy the files remotely."* what OS does your build run on? what OS runs the host you need to copy from? How can you access this files? – Timothy Truckle Feb 10 '17 at 11:16
  • But... I thought you decided to use the Wagon Plugin with regard to your latest questions?! It was built for this and [you used it successfully](http://stackoverflow.com/questions/42142901/how-to-execute-the-shell-scripts-using-maven#comment71461799_42142901)? Why post so many unanswered question as well? This isn't really nice since you give no context here... – Tunaki Feb 10 '17 at 11:16
  • @Tunaki that was for executing the script which runs successfully. I now need to transfer the .txt results back into maven. I thought I could've achieved this using maven-ant-run but turns out you can only send one file from remote to local. Can I use wagon to achieve this? – lualover2017 Feb 10 '17 at 11:19
  • Yes, you can. See the download goal http://www.mojohaus.org/wagon-maven-plugin/download-mojo.html and usage here http://www.mojohaus.org/wagon-maven-plugin/usage.html under "Configuration example to download.". Anytime you need to perform remote operations, the Wagon Plugin has a tool to do it. – Tunaki Feb 10 '17 at 11:21
  • @Tunaki Thanks will have a look and try that out – lualover2017 Feb 10 '17 at 11:24
  • @Tunaki So I've managed to configure it and it does locate the .txt files. It tries transferring it but it gets stuck when downloading the file. I'll update my post to show my pom and output – lualover2017 Feb 10 '17 at 11:36
  • @Tunaki I've edited my post. See the pom and output – lualover2017 Feb 10 '17 at 11:42
  • Do you have the correct permissions on the file? Can you download it using another tool just to test? – Tunaki Feb 10 '17 at 12:39
  • @Tunaki I've managed to get it working. Weird because it started working as soon as I restarted eclipse. Thanks for the help though! – lualover2017 Feb 10 '17 at 13:16

0 Answers0