MPHIBERNATE-12: new goal that generates POJOs from HBM files (hibernate:code-generation)
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@125458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
9e4136d82d
commit
38b4d952bb
17 files changed
+597
-5
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<project xmlns:util="jelly:util"
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:assert="assert"
|
||||
xmlns:maven="jelly:maven"
|
||||
xmlns:x="jelly:xml"
|
||||
default="testPlugin">
|
||||
|
||||
<goal name="testPlugin" prereqs="test-hibernate-code-generation">
|
||||
<attainGoal name="clean"/>
|
||||
</goal>
|
||||
|
||||
|
||||
<goal name="test-hibernate-code-generation">
|
||||
|
||||
<!-- definitions -->
|
||||
<j:set var="maven.hibernate.codeGeneration.input.excludes" value="org/apache/maven/hibernate/Item.hbm.xml,org/apache/maven/hibernate/ExcludeItem.hbm.xml"/>
|
||||
<j:set var="itemJavaPath" value="org/apache/maven/hibernate/Item.java"/>
|
||||
<j:set var="itemJavaFullPath" value="${maven.hibernate.codeGeneration.input.dir}/${itemJavaPath}"/>
|
||||
<j:set var="excludeItemJavaPath" value="org/apache/maven/hibernate/ExcludeItem.java"/>
|
||||
<j:set var="excludeItemJavaFullPath" value="${maven.hibernate.codeGeneration.input.dir}/${excludeItemJavaPath}"/>
|
||||
<j:set var="messageJavaFullPath" value="${maven.hibernate.codeGeneration.output.dir}/org/apache/maven/hibernate/Message.java"/>
|
||||
|
||||
<!-- makes sure there was an Item.java before -->
|
||||
<assert:assertFileExists file="${itemJavaFullPath}"/>
|
||||
|
||||
<util:loadText var="preItemContent" file="${itemJavaFullPath}"/>
|
||||
<attainGoal name="hibernate:code-generation"/>
|
||||
<util:loadText var="postItemContent" file="${itemJavaFullPath}"/>
|
||||
|
||||
<!-- makes sure Item.java was not generated -->
|
||||
<assert:assertEquals expected="${preItemContent}" value="${postItemContent}"/>
|
||||
|
||||
<!-- makes sure ExcludeItem.java was not generated -->
|
||||
<assert:assertFileNotFound file="${excludeItemJavaFullPath}"/>
|
||||
|
||||
<!-- makes sure Message.java was generated -->
|
||||
<assert:assertFileExists file="${messageJavaFullPath}"/>
|
||||
<attainGoal name="java:compile"/>
|
||||
<delete file="${messageJavaFullPath}"/>
|
||||
|
||||
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,20 @@
|
||||
# -------------------------------------------------------------------
|
||||
# Copyright 2004 The Apache Software Foundation.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# -------------------------------------------------------------------
|
||||
maven.hibernate.quiet=false
|
||||
maven.hibernate.codeGeneration.input.dir=${maven.src.dir}/main
|
||||
maven.hibernate.codeGeneration.output.dir=${maven.hibernate.codeGeneration.input.dir}
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
|
||||
<project>
|
||||
<pomVersion>3</pomVersion>
|
||||
<id>test-maven-hibernate-plugin-codeGenerationTest</id>
|
||||
<name>Test Cases for Maven Hibernate Plugin's CodeGeneration Tag</name>
|
||||
<groupId>maven</groupId>
|
||||
<currentVersion>1.0-SNAPSHOT</currentVersion>
|
||||
<organization>
|
||||
<name>Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
<logo>http://maven.apache.org/images/jakarta-logo-blue.gif</logo>
|
||||
</organization>
|
||||
<inceptionYear>2005</inceptionYear>
|
||||
<package>org.apache.maven</package>
|
||||
<logo>http://maven.apache.org/images/maven.jpg</logo>
|
||||
<description>Test for Maven Hibernate plugin</description>
|
||||
<shortDescription>Test for Maven Hibernate plugin</shortDescription>
|
||||
<url>http://maven.apache.org/reference/plugins/hibernate/</url>
|
||||
<siteDirectory>/www/maven.apache.org/reference/plugins/hibernate/</siteDirectory>
|
||||
<repository>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/hibernate/src/plugin-test</connection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/hibernate/src/plugin-test</url>
|
||||
</repository>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Felipe Leme</name>
|
||||
<id>felipeal</id>
|
||||
<email>maven@felipeal.net</email>
|
||||
<organization>Falcon Informatica</organization>
|
||||
<roles>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
<timezone>-3</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly-tags-xml</artifactId>
|
||||
<version>20030211.142705</version>
|
||||
<url>http://jakarta.apache.org/commons/jelly/libs/xml/</url>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>hibernate</groupId>
|
||||
<artifactId>hibernate</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.4</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<class
|
||||
name="org.apache.maven.hibernate.ExcludeItem"
|
||||
table="EXCLUDE_ITEMS">
|
||||
<id
|
||||
name="id"
|
||||
type="java.lang.Long"
|
||||
column="EXCLUDE_ITEM_ID">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property
|
||||
name="name"
|
||||
type="java.lang.String"
|
||||
column="EXCLUDE_ITEM_NAME"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
|
||||
|
||||
<hibernate-mapping auto-import="false">
|
||||
|
||||
<class name="org.apache.maven.hibernate.Item" table="Item" >
|
||||
<id name="id" type="int" column="ID" unsaved-value="0">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="name" column="NAME" type="string"/>
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package org.apache.maven.hibernate;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to use with testing the plugin.
|
||||
*
|
||||
* @author <a href="mailto:epugh@opensourceconnections.com">Eric Pugh</a>
|
||||
*
|
||||
* @version $Id: Item.java 125453 2005-01-18 01:03:25Z felipeal $
|
||||
*/
|
||||
|
||||
public class Item {
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* @return Returns the id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* @param id The id to set.
|
||||
*/
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @param name The name to set.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<class
|
||||
name="org.apache.maven.hibernate.Message"
|
||||
table="MESSAGES">
|
||||
<id
|
||||
name="id"
|
||||
type="java.lang.Long"
|
||||
column="MESSAGE_ID">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property
|
||||
name="text"
|
||||
type="org.apache.maven.hibernate.UserType"
|
||||
column="FIELD_TEXT"/>
|
||||
<property
|
||||
name="field"
|
||||
type="java.lang.String"
|
||||
column="MESSAGE_TEXT"/>
|
||||
<many-to-one
|
||||
name="nextMessage"
|
||||
class="org.apache.maven.hibernate.Message"
|
||||
cascade="all"
|
||||
column="NEXT_MESSAGE_ID"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.apache.maven.hibernate;
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to use with testing the plugin.
|
||||
*
|
||||
* @author <a href="paulkearney@gmail.com">Paul Kearney</a>
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class UserType {
|
||||
|
||||
private Long field;
|
||||
|
||||
private Message message;
|
||||
|
||||
|
||||
|
||||
public Long getField() {
|
||||
return field;
|
||||
}
|
||||
public void setField(Long field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user