• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • 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)
  • 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)

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.

<?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.

JPA MetaModel Ant

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

Category: HibernateTag: 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.

Previous Post: « JPA 2 MetaModel Generation using Eclipse
Next Post: How To Generate Javadoc With Ant »

Reader Interactions

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.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

EJB 3.0 Timer Services

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact