Building the project with Ant

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Code Generator > Generating Java code >

Building the project with Ant

Apache Ant is a widely used Java library (and command-line tool) which automates building and compilation of Java projects (see http://ant.apache.org/manual/). Ant works with build files (such files define the sources and targets from which code must be compiled, as well as any specific build options). Since any MapForce-generated project includes a build.xml file recognized by Ant, you can easily build MapForce-generated projects with Ant.

 

Ant may be available on your system either as a standalone installation, or bundled within Eclipse (or other Java IDEs). For instructions on how to install Ant on your system, see http://ant.apache.org/manual/. For instructions on how to use Ant in Eclipse, refer to the Eclipse tutorial, as well as the Eclipse documentation.

 

You can quickly check whether the standalone version of Ant (not the one bundled with Eclipse) is available on your system by opening a command prompt and typing ant at the command line. When Ant is already available, the resulting message will be similar to: Buildfile: buildxml does not exist! This message indicates that Ant is installed and it is attempting to build a build.xml file, but the latter does not exist in the current directory. If you run Ant from a directory which includes a build.xml file, Ant executes the build.xml file instead, with whatever build options are defined in it.

 

 

To build a MapForce-generated Java project with Ant:

1.Open a command prompt and navigate to the directory where the Java project was generated (note that the directory must contain the build.xml file).
2.At the command prompt, enter ant. This will compile and execute the Java code according to the options defined in the build.xml file.

codegen-java-ant-comp-exe

 

To generate a JAR file with Ant:

At the command prompt, enter ant jar.

 

If you need help with Ant command syntax and options, enter ant -help at the command line.


© 2019 Altova GmbH