Access the remote server from ANT

We need to move all latest java files from local machine to server using ANT.
How do we write buil.xml file?
Can someone please help us?
czutshiAsked:
Who is Participating?
 
ozlevanonConnect With a Mentor Commented:
That depends on what kind of access you have to the  server machine. If you have an FTP server on the remote machine, you can use an FTP task (http://ant.apache.org/manual/OptionalTasks/ftp.html).
If you access the remote machine using SSH telnet, you can use SCP, which does a secure copy over SSH (http://ant.apache.org/manual/OptionalTasks/scp.html).

Here a short snippet of the scp task (replace the ${} parts with the actual values). Note that if you do use SCP task you'll need ant-jsch.jar in your classpath (see http://stackoverflow.com/questions/2374105/ant-scp-task-not-working-even-with-jsch-on-ant-lib)

<scp todir="${scp.user}@${scp.host}:${scp.target.dir}" password="${scp.password}"
                   trust="true">
                  <fileset dir="${base.dir}/src" includes="**/*.java"/>
            </scp>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.