# Using the Ant task for the Castor DDL Generator

Describes how to use the Ant task for the Castor DDL Generator and its features.

An alternative to using the command line as shown in the previous section, the Castor DDL Generator Ant Task can be used to call the DDL generator for class generation. The only requirement is that the castor-<version>-anttasks.jar must be made available to your Ant installation.

## Configuration

Please find below the complete list of parameters that can be set on the Castor source generator.

Attribute | Description | Required?
--- | --- | ---
file | The name of the Castor JDO mapping file to use as input for DDL generation. | Yes
ddlFileName | The name of the DDL file to be generated. | Yes
databaseEngine | The name of database engine to generate DDL for. | Yes
globalProperties | Name of a custom (global) properties file to be used during DDL generation. | No
databaseEngineProperties | Name of a custom database specific properties file to be used during DDL generation. | No

Alternatively to specifying the file property, it is possible to work with a nested <FileSet> element or with the dir property.

## Example

Below is an example of how to use this task from within an Ant target definition named 'castor:ddl:src':

    <target name="castor:ddl:src" depends="init"
               description="Generate a DDL script from a JDO mapping file.">

      <taskdef name="castor-ddlgen"
               classname="org.castor.anttask.CastorDDLGenTask"
               classpathref="castor.class.path" />
      <mkdir dir="generated" />
      <castor-ddlgen file="src/main/resources/mapping.xml"
                     ddlFileName="target/generated/ddl/mapping.sql"
                     databaseEngine="mysql"/>
    </target>