In my previous article I have explained how to generate metamodel using your Eclipse IDE. However, in most scenarios you will have to create from your build scripts. This tutorial explains how to add this option in your ant script. For the detailed explanation on project example code, please refer the previous post. Here I explain only the build script.
JPA 2 MetaModel Generator Using Ant Script
In the below script, compiler argument -proc:only, tells that only to process the meta annotated classes.
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <project basedir="." default="antan" name="Annotation"> <property environment="env" /> <property name="target" value="1.6" /> <property name="source" value="1.6" /> <property name="src.dir" value="${basedir}/src" /> <property name="target.dir" value="${basedir}/target" /> <property name="src.lib" location="${basedir}" /> <path id="classpath"> <fileset dir="${src.lib}"> <include name="*.jar" /> </fileset> </path> <target name="antan"> <javac srcdir="${src.dir}" destdir="${target.dir}" failonerror="false" fork="true"> <compilerarg value="-proc:only"/> <classpath refid="classpath" /> </javac> </target> </project>
Project Structure
The files are generated to “target” folder in your project.
Hope this helps. You can just use the above script for generating the metamodel for your JPA projects.