Tag Archives: Eclipse

Activating Missing Ant Plugin in PDT Eclipse

ant-with-eclipse-header

Did you ever wonder why there is no Ant support in your Eclipse installation?

If you are working with Eclipse as your standard IDE for PHP Projects you will probably use the PDT Eclipse environment which doesn’t include much of the Java project tools. Ant is one of the very handy ones.


What is Ant?

With Ant you can write simple and as well sophisticated batch jobs for compiling and deploying your code or any other task you could think of. For an example, I’m using Ant to compress and obfuscate my Javascript and CSS files.


How does it work?

Tasks you would like to be processed with Ant you put in a build.xml file.
Here is a simple example:

1
2
3
4
5
6
7
8
9
10
11
12
 <target name="myTarget" depends="myTarget.check" if="myTarget.run">
     <echo>Files foo.txt and bar.txt are present.</echo>
 </target>
 
 <target name="myTarget.check">
     <condition property="myTarget.run">
         <and>
             <available file="foo.txt"/>
             <available file="bar.txt"/>
         </and>
     </condition>
 </target>

To learn how to write your own build files checkout the Ant Manual.


Activating Ant in Eclipse

  1. In Eclipse go to Help -> Software Updates -> Available Software
  2. Select Java Development Tools and install it
  3. Restart Eclipse

Now you should be able to see Ant in your Eclipse Preferences and when you right-click on a build.xml file in your project you can run it via Run As -> Ant Build.