Wednesday, November 9, 2011

Ant - Run

To run Ant and build the HelloWorld.jar, give the following command:
> ant dist

This tells Ant to run the 'dist' target.
Because 'dist' depends on 'compile' which depends on 'init', Ant will automatically run all three in the order init, compile, dist.

You can then run HelloWorld from the target directory (see below):

 C:\users\LavanniM\confucius>ant dist  
 Buildfile: C:\users\LavanniM\confucius\build.xml  
   
 init:  
   
 compile:  
   [javac] C:\users\LavanniM\confucius\build.xml:8: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds  
   
 dist:  
    [jar] Building jar: C:\users\LavanniM\confucius\target\HelloWorld.jar  
   
 BUILD SUCCESSFUL  
 Total time: 0 seconds  
   
 C:\users\LavanniM\confucius>cd target  
   
 C:\users\LavanniM\confucius\target>java -jar HelloWorld.jar  
 0 [main] DEBUG HelloWorld - Hello World!  
   
 C:\users\LavanniM\confucius\target>  


Note - you can ignore the includeantruntime warning if you get it - its a known and harmless bug in Ant 1.8

No comments: