3.15.1.1. Common Ant Configuration Options
All OpenJPA tasks accept a nested config element, which defines the configuration environment in which the specified task will run.
The attributes for the config tag are defined by the
JDBCConfiguration bean methods.
Note that excluding the config element will cause the Ant task to use the default system configuration mechanism, such as the configuration defined in the org.apache.openjpa.xml file.
Following is an example of how to use the nested config tag in a build.xml file:
<mappingtool>
<fileset dir="${basedir}">
<include name="**/model/*.java" />
</fileset>
<config connectionUserName="scott" connectionPassword="tiger"
connectionURL="jdbc:oracle:thin:@saturn:1521:solarsid"
connectionDriverName="oracle.jdbc.driver.OracleDriver" />
</mappingtool>
It is also possible to specify a properties or
propertiesFile attribute on the config tag, which will be used to locate a properties resource or file.
The resource will be loaded relative to the current CLASSPATH.
<mappingtool>
<fileset dir="${basedir}">
<include name="**/model/*.java"/>
</fileset>
<config properties="openjpa-dev.xml"/>
</mappingtool>
<mappingtool>
<fileset dir="${basedir}">
<include name="**/model/*.java"/>
</fileset>
<config propertiesFile="../conf/openjpa-dev.xml"/>
</mappingtool>
Tasks also accept a nested classpath element, which you can use in place of the default classpath.
The classpath argument behaves the same as it does for Ant’s standard javac element.
It is sometimes the case that projects are compiled to a separate directory than the source tree.
If the target path for compiled classes is not included in the project’s classpath, then a classpath element that includes the target class directory needs to be included so the enhancer and mapping tool can locate the relevant classes.
Following is an example of using a classpath tag:
<openjpac>
<fileset dir="${basedir}/source">
<include name="**/model/*.java" />
</fileset>
<classpath>
<pathelement location="${basedir}/classes"/>
<pathelement location="${basedir}/source"/>
<pathelement path="${java.class.path}"/>
</classpath>
</openjpac>
Finally, tasks that invoke code-generation tools like the application identity tool and reverse mapping tool accept a nested codeformat element.
See the code formatting documentation in Code Formatting for a list of code formatting attributes.
<reversemappingtool package="com.xyz.jdo" directory="${basedir}/src">
<codeformat tabSpaces="4" spaceBeforeParen="true" braceOnSameLine="false"/>
</reversemappingtool>