Eclipse simplifies the process of deploying your site to a web server. You can even use Ant, traditionally thought of as a Java tool, to help you in the deployment. This article, the second of two parts, explains how. It is excerpted from PHPEclipse: A User Guide, written by Shu-Wai Chow (Packt Publishing, 2006; ISBN: 1904811442).
Deploying your Site with PHPEclipse, continued - Running an Ant Script (Page 2 of 4 )
To run an Ant Script, select the build.xml file in the Navigator view. Select the Run | External Tools | Run As | Ant Build menu option. Eclipse will automatically trigger the build file. The results of our execution will be output in the Console view.
Buildfile: /Library/WebServer/Documents/ ShelterSite/build.xml startPublish: getFilesFromCVS: [cvs] cvs checkout: Updating ShelterSite [cvs] U ShelterSite/.project [cvs] U ShelterSite/CatAction.php [cvs] U ShelterSite/ViewCats.php [cvs] cvs checkout: Updating ShelterSite/classes [cvs] U ShelterSite/classes/clsCat.php [cvs] U ShelterSite/classes/clsCatView.php [cvs] U ShelterSite/classes/clsDatabase.php [cvs] U ShelterSite/classes/clsPet.php [cvs] cvs checkout: Updating ShelterSite/styles [cvs] U ShelterSite/styles/shelter.css startFTP: [ftp] sending files [ftp] 7 files sent cleanUp: [delete] Deleting directory /tmp/ShelterSite BUILD SUCCESSFUL Total time: 8 seconds
If there are any errors during the execution, they will also output here to help you troubleshoot.
Avoid Putting FTP Passwords in Build Files
You may want to avoid putting passwords in build files, since they are simple text files. To do this, reference them with a dollar sign and bracket: ${ftpPassword}. When you execute the file, pass in an argument. To pass Ant arguments in Eclipse, go to the Run | External Tools | External Tools… menu option. Ant files have configuration profiles much like debugging configurations. This window will pull up the configuration for a particular Ant file. Highlight the build file you wish to work with and in the Main tab's Arguments area, type in –DftpPassword="YourSecretPassword" where ftpPassword is the name of the variable you specified in the build file and the enclosing quotes hold your password. Note the dash at the beginning of the argument and that there is no space after the D flag and the variable name.