Working With ANT

26 April 2007

ANT is a Java build tool. It is very easy to use ANT in Eclipse. For example, you have a simple Java project with following code:

public class HelloWorld {

public static void main(){

 	System.out.println("Hi");

 }

public void hi()

 {

 	System.out.println("Hi");

 }

}

And you want to compile it and place the class file into the build folder. This can be done using ANT. To create and ANT file, follow these steps In Eclipse IDE:

  1. ” File ” - > ” New ” - > ” File ” - > filename.xml.Extension of file should be xml.
  2. Change the default editor for a XML file to the Ant Editor. This can be done as follows:
    • ” Window ” - > ” Preferences ” - > ” Workbench ” - > ” File Associations “.
    • Click ” Add ” to add a new extension, type *.xml and click OK.
    • Select it from File Types box, and in the Associated Editors box click ” Add “.
    • Select Ant Editor.
  3. Now in the ANT file, paste following code:
  4. 
    
    
    
         
              
         
         
              
         
    
  5. Right click the file and click “Open with ” - > ” Ant Editor “.
  6. You should make Outline view visible. This can help you in writing ANT files. This can be done as follows:

  7. ” Window ” - > ” Show View ” - > ” Outline “.
  8. You will notice that there will be entries for each property and each target.

  9. Now we have everything set. We will now run ANT file. Select ANT file from the Navigator and choose ” Run ” - > ” External Tools ” from its context menu. The External Tools dialog will appears. Click ” New ” to create a new configuration. Make the required settings and click ” Run “. The Ant buildfile will run and you can check the console.

Related Posts:


    Fatal error: Call to undefined function related_posts() in /home/blog/public_html/eclipse-blog/wp-content/themes/Andreas 08 3 columns/single.php on line 23