Why use Ant?
Ant is a defacto built tool for compiling, building, packaging, testing and many other Java project related task.
So why not use Ant to perform basic Server Side Java operation with Oracle.
Here a simple list of motivations:
after rebuild some packages automatically upload new jars to the test/production environment
independence of the build environment (Windows, Unix)
parametrized build scripts using properties
integrated build environment with other J2EE related projects
So which server side related tasks can be automatized?
loadjava and dropjava
JPublisher object types
NComp classes for Oracle 10g
To re-use this functionality across all the projects we built Ant's macros.
Using Ant's macros on your build.xml files
You can simply import the above files in your build.xml and start using it, all macros assume that ORACLE_HOME environment variable is properly set, either to an Oracle 10g/11g home directory or to a base directory of JDeveloper 10g/11g.
If you use JDeveloper layout directory SQLPlus and NComp macros will not work unless you copy sqlplus and ncomp binary files at jdev_home/bin directory and creates a directory network/admin with the tnsnames.ora file inside.
A little trick to use JDeveloper as Oracle Home layout directory is to install Oracle Instant Client package and perform the above steps.
Here a simple build.xml file which uses ncomp and loadjava macros, each XML file also has examples of usage inside.
Note about SQLPlus: Ant provides a JDBC task to perform basic SQL operations but have several limitations, one for example it can not log as sysdba.