I had a similar problem recently. On a windows system, with Eclipse it came down to verifying:
- that ANT works
- SCP works by itself,
- that ANT and SCP worked within the Eclipse development environment.
A simple ANT file can be run within eclipse named build.xml
.
Sample contents would be:
<?xml version="1.0" encoding="UTF-8"?>
<project default="main" basedir=".">
<echo message="A 'testant' task."/>
<target name="main" >
<scp trust="yes" file="testfileinRootDirectory.xml" todir="username:password@hostname.org.domain:/home/username/existingfolder"/>
</target>
</project>
If you can run this from within Eclipse, then you have some form of ANT working, and also have some form of WinSCP working.
If you cannot get it working in Eclipse, then open a command window in the directory that has the build.xml and run ant
from a command prompt. (It will pick up and run a build.xml file automatically).
If it does not work, then check the entries that you have within Eclipse - as it could be using a different set of paths for ANT than a command line run of Maven might be. From within Eclipse check out:
Window|
Preferences|
Ant|
Runtime|
Examing the Classpath entries.
The Ant Home Entry may be Eclipse specific: e.g.: c:\eclipse\plugins\org.apache.ant_1.8.3_v20120321-1730\lib
The Global Entries may be different (e.g. your installation location) - such as c:\dev\ant
- or wherever your %ANT_HOME% directory has been set to be after an installation.
Eclipse however may be searching for SCP jars in the c:\Users\username\.ant\lib
directory.
One possible solution:
- Install ANT to the c:\Users\username\.ant
directory
- Set the ANT_HOME to be c:\Users\username\.ant
- Within Eclipse set the Ant Home option (same screen as the Runtime
options) to be same as that on a command line
(c:\Users\username\.ant
).
Note:
A possible disadvantage is that the User and System settings may be the same for ANT, however you just need to get the optional jars into one location in future in order to get things working.
Testing Maven:
Similar to Raghuram's answer above, getting the dependecies right is important.
Use the full sample code from Cedric Walter's page - Apache Maven copy local file to a remote server server using SSH