JavaBeat

  • Home
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Privacy
  • Contact Us

JPA 2 MetaModel Generator using Ant

December 27, 2013 by Krishna Srinivasan Leave a Comment

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.

Java Persistence API (JPA)

JPA 2 MetaModel Generator Using Ant Script

In the below script, compiler argument -proc:only, tells that only to process the meta annotated classes.

[code lang=”xml”]
<?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>
[/code]

Project Structure

The files are generated to “target” folder in your project.

JPA MetaModel Ant

Hope this helps. You can just use the above script for generating the metamodel for your JPA projects.

Filed Under: Hibernate Tagged With: Apache Ant, Hibernate 4 Tutorials, JPA 2 Tutorials

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow Us

  • Facebook
  • Pinterest

As a participant in the Amazon Services LLC Associates Program, this site may earn from qualifying purchases. We may also earn commissions on purchases from other retail websites.

JavaBeat

FEATURED TUTORIALS

Answered: Using Java to Convert Int to String

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Copyright © by JavaBeat · All rights reserved