Internetagentur

Eclipse 3.6 & Ant: Working with files on a remote FTP server


I am currently working on a resource intensive application. My Laptop is to slow to effeciently run the application. Therefore I am writing the code on my laptop using Eclipse PDT and I am running the application on a high performance remote server. Therefore I need to continously publish changed files via FTP to the server in order to be able to test them and to work as integrated as possible. Therefore I was looking for according possibilities in Eclipse.

So far I did not succeed discovering a satisfying solution in Eclipse which allows to continously only upload updated files and to use the IDE features  provided by PDT. Finally I ended up using Netbeans for that project, because it offered exactly what I needed and worked perfectly out of the box (is set up in minutes - see Netbeans remote synchronization). It would be great to hear if someone knows a good solution to accomplish this in Eclipse.    

I evaluated the following possibilities in Eclipse to work with files on a remote server via FTP:

Remote System Explorer (Target Management) (http://www.eclipse.org/tm/): This works basically similar to a FTP Client but a litle more automated. Basically you establish a FTP connection to your server and remotely edit the files on the server in Eclipse. Files are automatically uploaded upon save. The disadvantage: This reduces the features you can use in Eclipse to a "simple" editor. Remote System Explorer has its own perspective.

Ant Build Process: If you want to use advanced IDE features (e.g. PDT-features like syntax highlighting, code assist and code folding, remote debugging etc.) you can work with (automated) builds using Ant. You are editing your project locally as usual. When finished with editing you can start a build process (manually or continously automatically) which uploads all (changed) files to your FTP server. The problem with this was: So far it seems Ant can not only track the source files and only upload these having changed. On each save it will scan full source and destination for changes which will make it pretty slow and useless in large projects for continous file upload. 

Installing & Configuring Ant with Eclipse 3.6 on Windows

  • Go to Help -> Install New Software:
  • Select from Available Software Sites: Helios - http://download.eclipse.org/releases/helios
  • Go to "General Purpose Tools" and make sure "Eclipse Plug-in Development Environment" is installed. If not install and restart Eclipse.

          

  • Download the Jakarta Apache Commons Library http://jakarta.apache.org/commons/net/index.html. Unzip the library and store the  Jcommons-net-3.0.1.jar in your Eclipse library.
  • Go to Window -> Preferences -> Ant -> Runtime
    • Add the Jcommons-net-3.0.1.jar to the classpath (e.g. in Ant Home Entries)
    • Add the tools.jar to the classpath (typically found in the lib directory of your JDK directory e.g. C:/Program Files/jdk1.6.0_26/lib/tools.jar)
  • Sometimes Ant needs to be activated for first usage:
    • Go to File -> New -> Other: Show all wizards and go to "Java" and select "Java Project from Existing Ant Buildfile". Proceed with "Next". If a dialog asks “Always enable activities and don´t ask me again” confirm that. Afterwards cancel the wizard.
  • Now you need to create an Ant build.xml file in your project directory

<?xml version="1.0" ?>
<project name="MyProject">
  <target name="ftp" description="SomeDescription">
  <ftp server     = "ftp.domain.com"
       userid     = "userABC"
    password     = "passwordABC"
    remotedir     = "/dev/"
    passive     = "no"
    binary     = "no"
    depends     = "yes"
    verbose     = "yes"
    timestampGranularity  = "NONE" >
      <fileset dir="G:/Inetpub/wwwroot2/dev">
      </fileset>
  </ftp> 
 </target>
</project>

  •  Having created the build file you can use Ant the following ways:

1. Manually from the Ant view: Go to Window -> Show View -> Other -> Ant -> Ant: Afterwards you will see the Ant view. Drag&Drop your build.xml file into the view and start the build task manually when you need it

 

2. Automatically with builder (e.g. automatically each time the file is saved):

  • Go to Project -> Properties -> Builders   
  • Select "Import..." => Choose your build.xml file
  • Edit the configuration of the created Ant task 
  • Tab Targets: Set target to ftp where appropriate
  • Close Dialog
  • If appropriate activate Project -> Properties -> Build Automatically

COMMENTS

 
    No recent messages have been posted.

Please enter your message:

* = required field
  •   
  •   

  • Please enter here the word as displayed in the picture. This is to prevent spamming.
    CAPTCHA image for SPAM prevention