|  |  |  | License Codehaus OpenEJB OpenJMS OpenORB Tyrex

Old releases
General
Release 1.3
Release 1.3rc1
Release 1.2

Main
Home
About
Features
Download
Dependencies
Reference guide
Publications
JavaDoc
Maven 2 support
Maven 2 archetypes
DTD & Schemas
Recent HTML changes
News Archive
RSS news feed
Project Wiki

Development/Support
Mailing Lists
SVN/JIRA
Contributing
Support
Continuous builds
Prof. services

Related projects
Spring ORM support
Spring XML factories
WS frameworks

XML
XML

XML Code Generator
XML Code Generator

JDO
Introduction
First steps
Using JDO
JDO Config
Types
JDO Mapping
JDO FAQ
JDO Examples
JDO HOW-TOs
Tips & Tricks
Other Features
JDO sample JAR

Tools
Schema generator

Advanced JDO
Caching
OQL
Trans. & Locks
Design
KeyGen
Long Trans.
Nested Attrs.
Pooling Examples
LOBs
Best practice

DDL Generator
Using DDL Generator
Properties
Ant task
Type Mapping

More
The Examples
3rd Party Tools
JDO Tests
XML Tests
Configuration

About
License
User stories
Contributors
Marketplace
Status, Todo
Changelog
Library
Contact
Project Name

## Using the Ant task for the Castor DDL Generator

Documentation Author(s):
Werner Guttmann

Castor DDL generator Ant task
Configuration
Example

## Castor DDL generator Ant task

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 on the CLASSPATH.

### 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>

<notice> Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. </notice>
<notice> Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners. </notice>