Categories
Java

Simple Apache Ant script example

In one of my post I discussed about connecting to PostgreSQL with Java. On that time in order to compile and run the app I used Bash script. Now in this post I would like to deprecate the script and use Ant (build.xml) instead of it.

Basically Ant is a software tool for automating software build processes. Ant runs the file called build.xml and it has structure similar to following,

The following is a conventional Apache Ant structure. Those sections which I wrote with capital letters are most important. One is your project name, another one is the name of your jar file and the last one which is the most crucial one is your main class name. If you do not identify your main class name then the ant throws exception on the case that you have more than one class to compile.

You should also bear in mind of the library you want to include inside of your Jar file. I personally highly recommend this practice because after running Ant script, you would have a single and unify Jar file with all your project dependency which is very clean and you can deploy it without being worry of libs or anything else because all of your dependency libs are added in Jar file. You can introduce your libraries in pathelement section.

Exit mobile version