MPHIBERNATE-6, allow multiple base dirs and new aggregate-mappings goal.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2cf4614c2
commit
7d12066937
@ -24,15 +24,23 @@
|
||||
xmlns:h="jelly:org.apache.maven.hibernate.jelly.HibernateTagLibrary">
|
||||
|
||||
<goal name="hibernate:init">
|
||||
|
||||
<ant:mkdir dir="${maven.hibernate.output.dir}"/>
|
||||
</goal>
|
||||
|
||||
<goal name="hibernate:aggregate-mappings" prereqs="hibernate:init" description="Aggregate multiple .hbm.xml files into one file">
|
||||
|
||||
<ant:echo>Aggregating multiple hibernate mapping into one single file</ant:echo>
|
||||
|
||||
<h:aggregate-mappings
|
||||
aggregateOutputFile="${maven.hibernate.aggregate.output.file}"
|
||||
basedir="${maven.hibernate.input.dir}"
|
||||
includes="${maven.hibernate.input.includes}"
|
||||
excludes="${maven.hibernate.input.excludes}"/>
|
||||
</goal>
|
||||
|
||||
<goal name="hibernate:schema-export" prereqs="hibernate:init" description="Export Hibernate schema">
|
||||
|
||||
<ant:echo>Exporting Hibernate Schema file</ant:echo>
|
||||
<ant:mkdir dir="${maven.hibernate.output.dir}"/>
|
||||
|
||||
<h:schema-export
|
||||
properties="${maven.hibernate.properties}"
|
||||
|
||||
@ -23,4 +23,5 @@ maven.hibernate.output.dir=${maven.build.dir}/schema
|
||||
maven.hibernate.output.file=${maven.hibernate.output.dir}/${maven.final.name}-schema.sql
|
||||
maven.hibernate.input.dir=${maven.build.dest}
|
||||
maven.hibernate.input.includes=**/*.hbm.xml
|
||||
maven.hibernate.input.excludes=
|
||||
maven.hibernate.input.excludes=
|
||||
maven.hibernate.aggregate.output.file=${maven.hibernate.output.dir}/aggregated-mappings.hbm.xml
|
||||
@ -0,0 +1,148 @@
|
||||
package org.apache.maven.hibernate.beans;
|
||||
|
||||
/* ====================================================================
|
||||
* 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.tools.ant.DirectoryScanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="as851@columbia.edu">Alex Shneyderman</a>
|
||||
* @since $Id: CommonOperationsBean.java,v 1.1 2004/07/02 07:32:53 epugh Exp $
|
||||
*/
|
||||
public class CommonOperationsBean {
|
||||
|
||||
private String includes = null;
|
||||
private String excludes = null;
|
||||
private String basedir = null;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(CommonOperationsBean.class);
|
||||
|
||||
public String getBasedir()
|
||||
{
|
||||
return basedir;
|
||||
}
|
||||
|
||||
public void setBasedir(String basedir)
|
||||
{
|
||||
this.basedir = basedir;
|
||||
}
|
||||
|
||||
public String getExcludes()
|
||||
{
|
||||
return excludes;
|
||||
}
|
||||
|
||||
public void setExcludes(String excludes)
|
||||
{
|
||||
this.excludes = excludes;
|
||||
}
|
||||
|
||||
public String getIncludes()
|
||||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public void setIncludes(String includes)
|
||||
{
|
||||
this.includes = includes;
|
||||
}
|
||||
|
||||
protected String[] getBaseDirNames()
|
||||
{
|
||||
LOG.debug("Bases string: " + getBasedir());
|
||||
StringTokenizer st = new StringTokenizer(getBasedir(), ",");
|
||||
String r[] = new String[st.countTokens()];
|
||||
for(int i = 0; st.hasMoreTokens(); i++)
|
||||
r[i] = st.nextToken();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
protected File[] getBaseDirs()
|
||||
{
|
||||
String bases[] = getBaseDirNames();
|
||||
List l = new ArrayList();
|
||||
for(int i = 0; i < bases.length; i++)
|
||||
{
|
||||
File t = new File(bases[i]);
|
||||
if(t.isDirectory())
|
||||
{
|
||||
l.add(t);
|
||||
LOG.info(" Adding base dir: " + t.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
return (File[])l.toArray(new File[0]);
|
||||
}
|
||||
|
||||
protected String[] getFileNames()
|
||||
{
|
||||
List files = new LinkedList();
|
||||
File dirs[] = getBaseDirs();
|
||||
for(int i = 0; i < dirs.length; i++)
|
||||
{
|
||||
DirectoryScanner directoryScanner = new DirectoryScanner();
|
||||
directoryScanner.setBasedir(dirs[i]);
|
||||
LOG.debug("Base dir:" + dirs[i].getAbsolutePath());
|
||||
LOG.debug("Excludes:" + getExcludes());
|
||||
LOG.debug("Includes:" + getIncludes());
|
||||
directoryScanner.setExcludes(StringUtils.split(getExcludes(), ","));
|
||||
directoryScanner.setIncludes(StringUtils.split(getIncludes(), ","));
|
||||
directoryScanner.scan();
|
||||
String includesFiles[] = directoryScanner.getIncludedFiles();
|
||||
for(int j = 0; j < includesFiles.length; j++)
|
||||
{
|
||||
File file = new File(includesFiles[j]);
|
||||
if(!file.isFile())
|
||||
file = new File(directoryScanner.getBasedir(), includesFiles[j]);
|
||||
files.add(file.getAbsolutePath());
|
||||
LOG.debug("work with file:" + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (String[])files.toArray(new String[0]);
|
||||
}
|
||||
|
||||
protected File[] getFileDescriptors()
|
||||
{
|
||||
String names[] = getFileNames();
|
||||
List files = new ArrayList();
|
||||
for(int i = 0; i < names.length; i++)
|
||||
{
|
||||
File t = new File(names[i]);
|
||||
if(t.isFile())
|
||||
files.add(t);
|
||||
}
|
||||
|
||||
return (File[])files.toArray(new File[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,108 @@
|
||||
package org.apache.maven.hibernate.beans;
|
||||
|
||||
/* ====================================================================
|
||||
* 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="as851@columbia.edu">Alex Shneyderman</a>
|
||||
* @since $Id: MappingsAggregatorBean.java,v 1.1 2004/07/02 07:32:53 epugh Exp $
|
||||
*/
|
||||
public class MappingsAggregatorBean extends CommonOperationsBean
|
||||
{
|
||||
|
||||
private String aggregateOutputFile = null;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(MappingsAggregatorBean.class);
|
||||
|
||||
public void execute()
|
||||
throws Exception
|
||||
{
|
||||
String version = null;
|
||||
File files[] = getFileDescriptors();
|
||||
if(files == null || files.length <= 0)
|
||||
{
|
||||
LOG.info("nothing to process");
|
||||
return;
|
||||
}
|
||||
LOG.info("Aggregating to " + getAggregateOutputFile());
|
||||
File f = new File(getAggregateOutputFile());
|
||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
XMLWriter writer = new XMLWriter(new FileWriter(f), format);
|
||||
Document finalDoc = DocumentHelper.createDocument();
|
||||
Element rootHM = null;
|
||||
for(int i = 0; i < files.length; i++)
|
||||
{
|
||||
SAXReader reader = new SAXReader();
|
||||
Document current = reader.read(files[i]);
|
||||
String currentVersion = getVersion(current);
|
||||
if(version == null)
|
||||
{
|
||||
version = currentVersion;
|
||||
finalDoc.setProcessingInstructions(current.processingInstructions());
|
||||
finalDoc.setDocType(current.getDocType());
|
||||
rootHM = finalDoc.addElement("hibernate-mapping");
|
||||
} else
|
||||
if(!version.equals(currentVersion))
|
||||
{
|
||||
LOG.warn("Mapping in " + files[i].getName() + " is not of the same mapping version as " + files[0].getName() + " mapping, so merge is impossible. Skipping");
|
||||
continue;
|
||||
}
|
||||
for(Iterator iter = current.selectSingleNode("hibernate-mapping").selectNodes("class").iterator(); iter.hasNext(); rootHM.add((Element)((Element)iter.next()).clone()));
|
||||
}
|
||||
|
||||
writer.write(finalDoc);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public String getAggregateOutputFile()
|
||||
{
|
||||
return aggregateOutputFile;
|
||||
}
|
||||
|
||||
public void setAggregateOutputFile(String aggregateOutputFile)
|
||||
{
|
||||
this.aggregateOutputFile = aggregateOutputFile;
|
||||
}
|
||||
|
||||
private String getVersion(Document current)
|
||||
{
|
||||
String docType = current.getDocType().getText();
|
||||
if(docType == null || "".equals(docType.trim()))
|
||||
return "";
|
||||
if(docType.indexOf("hibernate-mapping-2.0.dtd") > 0)
|
||||
return "2.0";
|
||||
if(docType.indexOf("hibernate-mapping-1.1.dtd") > 0)
|
||||
return "1.1";
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,17 +22,15 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import net.sf.hibernate.HibernateException;
|
||||
import net.sf.hibernate.cfg.Configuration;
|
||||
import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.tools.ant.DirectoryScanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Bean which serves as Proxy To Hibernate API
|
||||
@ -41,28 +39,27 @@ import org.apache.tools.ant.DirectoryScanner;
|
||||
*
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: SchemaExportBean.java,v 1.4 2004/04/25 02:29:43 brett Exp $
|
||||
* @version $Id: SchemaExportBean.java,v 1.5 2004/07/02 07:32:53 epugh Exp $
|
||||
*/
|
||||
public class SchemaExportBean
|
||||
public class SchemaExportBean extends CommonOperationsBean
|
||||
{
|
||||
|
||||
private String includes = null;
|
||||
private String excludes = null;
|
||||
private String basedir = null;
|
||||
private String properties = null;
|
||||
private String config = null;
|
||||
private String outputFile = null;
|
||||
private String schemaOutputFile = null;
|
||||
private String delimiter = null;
|
||||
private boolean quiet = false;
|
||||
private boolean text = false;
|
||||
private boolean drop = false;
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(MappingsAggregatorBean.class);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getIncludes()
|
||||
public String getSchemaOutputFile()
|
||||
{
|
||||
return includes;
|
||||
return schemaOutputFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,9 +67,10 @@ public class SchemaExportBean
|
||||
*/
|
||||
public String getOutputFile()
|
||||
{
|
||||
return outputFile;
|
||||
return schemaOutputFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@ -92,17 +90,17 @@ public class SchemaExportBean
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public void setIncludes(String string)
|
||||
public void setSchemaOutputFile(String string)
|
||||
{
|
||||
includes = string;
|
||||
schemaOutputFile = string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public void setOutputFile(String string)
|
||||
{
|
||||
outputFile = string;
|
||||
schemaOutputFile = string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,14 +151,6 @@ public class SchemaExportBean
|
||||
properties = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getBasedir()
|
||||
{
|
||||
return basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@ -169,22 +159,6 @@ public class SchemaExportBean
|
||||
return drop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getExcludes()
|
||||
{
|
||||
return excludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public void setBasedir(String string)
|
||||
{
|
||||
basedir = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param b
|
||||
*/
|
||||
@ -193,14 +167,6 @@ public class SchemaExportBean
|
||||
drop = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public void setExcludes(String string)
|
||||
{
|
||||
excludes = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@ -237,23 +203,27 @@ public class SchemaExportBean
|
||||
try
|
||||
{
|
||||
|
||||
File baseDirFile = new File(getBasedir());
|
||||
URL[] urls = { baseDirFile.toURL()};
|
||||
System.out.println(urls[0]);
|
||||
URLClassLoader newClassLoader =
|
||||
File [] baseDirs = getBaseDirs ();
|
||||
URL [] urls = new URL [baseDirs.length];
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
urls [i] = baseDirs [i].toURL ();
|
||||
System.out.println(urls [i]);
|
||||
}
|
||||
|
||||
URLClassLoader newClassLoader =
|
||||
new URLClassLoader(urls, getClass().getClassLoader());
|
||||
currentThread.setContextClassLoader(newClassLoader);
|
||||
Configuration cfg = getConfiguration();
|
||||
SchemaExport schemaExport = getSchemaExport(cfg);
|
||||
currentThread.setContextClassLoader(newClassLoader);
|
||||
Configuration cfg = getConfiguration();
|
||||
SchemaExport schemaExport = getSchemaExport(cfg);
|
||||
|
||||
if (isDrop())
|
||||
{
|
||||
if (isDrop())
|
||||
{
|
||||
schemaExport.drop(!getQuiet(), !getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
schemaExport.create(!getQuiet(), !getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -261,40 +231,6 @@ public class SchemaExportBean
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds list of files for which will be included
|
||||
* in the schema. Uses ANT file scanner.
|
||||
*/
|
||||
private String[] getFiles()
|
||||
{
|
||||
|
||||
List files = new LinkedList();
|
||||
|
||||
DirectoryScanner directoryScanner = new DirectoryScanner();
|
||||
directoryScanner.setBasedir(getBasedir());
|
||||
|
||||
System.out.println("Excludes:" + getExcludes());
|
||||
System.out.println("Includes:" + getIncludes());
|
||||
System.out.println("Base dir:" + getBasedir());
|
||||
|
||||
directoryScanner.setExcludes(StringUtils.split(getExcludes(), ","));
|
||||
directoryScanner.setIncludes(StringUtils.split(getIncludes(), ","));
|
||||
|
||||
directoryScanner.scan();
|
||||
String[] includesFiles = directoryScanner.getIncludedFiles();
|
||||
for (int i = 0; i < includesFiles.length; i++)
|
||||
{
|
||||
File file = new File(includesFiles[i]);
|
||||
if (!file.isFile())
|
||||
{
|
||||
file = new File(directoryScanner.getBasedir(), includesFiles[i]);
|
||||
}
|
||||
files.add(file.getAbsolutePath());
|
||||
}
|
||||
String[] retValue = (String[]) files.toArray(new String[0]);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -306,7 +242,7 @@ public class SchemaExportBean
|
||||
cfg.configure(getConfig());
|
||||
}
|
||||
|
||||
String[] files = getFiles();
|
||||
String[] files = getFileNames ();
|
||||
for (int i = 0; i < files.length; i++)
|
||||
{
|
||||
String filename = files[i];
|
||||
@ -336,9 +272,10 @@ public class SchemaExportBean
|
||||
properties.load(new FileInputStream(getProperties()));
|
||||
schemaExport = new SchemaExport(cfg, properties);
|
||||
}
|
||||
System.out.println("Output file:" + getOutputFile());
|
||||
LOG.debug("Output file:" + getOutputFile());
|
||||
schemaExport.setOutputFile(getOutputFile());
|
||||
schemaExport.setDelimiter(getDelimiter());
|
||||
return schemaExport;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,81 @@
|
||||
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date: 7/1/2004 2:49:47 PM
|
||||
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
|
||||
// Decompiler options: packimports(3)
|
||||
// Source File Name: AggregateMappingsTag.java
|
||||
|
||||
package org.apache.maven.hibernate.jelly;
|
||||
|
||||
import org.apache.commons.jelly.*;
|
||||
import org.apache.maven.hibernate.beans.MappingsAggregatorBean;
|
||||
|
||||
public class AggregateMappingsTag extends TagSupport
|
||||
{
|
||||
|
||||
private MappingsAggregatorBean bean = new MappingsAggregatorBean();
|
||||
|
||||
protected void execute()
|
||||
throws JellyTagException
|
||||
{
|
||||
try
|
||||
{
|
||||
bean.execute();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
String msg = " Mapping aggreagtion failed: " + e.getMessage();
|
||||
throw new JellyTagException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void doTag(XMLOutput arg0)
|
||||
throws JellyTagException
|
||||
{
|
||||
execute();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return bean.toString();
|
||||
}
|
||||
|
||||
public void setExcludes(String string)
|
||||
{
|
||||
bean.setExcludes(string);
|
||||
}
|
||||
|
||||
public void setIncludes(String string)
|
||||
{
|
||||
bean.setIncludes(string);
|
||||
}
|
||||
|
||||
public String getExcludes()
|
||||
{
|
||||
return bean.getExcludes();
|
||||
}
|
||||
|
||||
public String getIncludes()
|
||||
{
|
||||
return bean.getIncludes();
|
||||
}
|
||||
|
||||
public String getBasedir()
|
||||
{
|
||||
return bean.getBasedir();
|
||||
}
|
||||
|
||||
public void setBasedir(String string)
|
||||
{
|
||||
bean.setBasedir(string);
|
||||
}
|
||||
|
||||
public String getAggregateOutputFile()
|
||||
{
|
||||
return bean.getAggregateOutputFile();
|
||||
}
|
||||
|
||||
public void setAggregateOutputFile(String aggregateOutputFile)
|
||||
{
|
||||
bean.setAggregateOutputFile(aggregateOutputFile);
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ import org.apache.commons.jelly.tags.core.CoreTagLibrary;
|
||||
* Hibernate tag library.
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: HibernateTagLibrary.java,v 1.2 2004/03/02 15:04:01 evenisse Exp $
|
||||
* @version $Id: HibernateTagLibrary.java,v 1.3 2004/07/02 07:32:52 epugh Exp $
|
||||
*/
|
||||
public class HibernateTagLibrary extends CoreTagLibrary
|
||||
{
|
||||
@ -34,6 +34,7 @@ public class HibernateTagLibrary extends CoreTagLibrary
|
||||
*/
|
||||
public HibernateTagLibrary()
|
||||
{
|
||||
registerTag( "schema-export", SchemaExportTag.class );
|
||||
registerTag( "schema-export", SchemaExportTag.class );
|
||||
registerTag( "aggregate-mappings", AggregateMappingsTag.class );
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ import org.apache.maven.hibernate.beans.SchemaExportBean;
|
||||
* to {@link SchemaExportBean}
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: SchemaExportTag.java,v 1.3 2004/03/02 15:04:01 evenisse Exp $
|
||||
* @version $Id: SchemaExportTag.java,v 1.4 2004/07/02 07:32:52 epugh Exp $
|
||||
*/
|
||||
public class SchemaExportTag extends TagSupport
|
||||
{
|
||||
@ -221,4 +221,15 @@ public class SchemaExportTag extends TagSupport
|
||||
{
|
||||
bean.setDelimiter(delimiter);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getSchemaOutputFile() {
|
||||
return bean.getSchemaOutputFile();
|
||||
}
|
||||
/**
|
||||
*/
|
||||
public void setSchemaOutputFile(String string) {
|
||||
bean.setSchemaOutputFile(string);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,11 @@
|
||||
<project xmlns:util="jelly:util"
|
||||
xmlns:j="jelly:core"
|
||||
xmlns:ant="jelly:ant"
|
||||
xmlns:assert="assert">
|
||||
xmlns:assert="assert"
|
||||
xmlns:x="jelly:xml">
|
||||
|
||||
<goal name="testPlugin" prereqs="test-hibernate-schema-export">
|
||||
<attainGoal name="clean"/>
|
||||
<goal name="testPlugin" prereqs="test-hibernate-schema-export,test-hibernate-aggregate-mappings">
|
||||
<!--attainGoal name="clean"/-->
|
||||
</goal>
|
||||
|
||||
<goal name="test-hibernate-schema-export">
|
||||
@ -29,7 +30,22 @@
|
||||
<attainGoal name="hibernate:schema-export"/>
|
||||
|
||||
<assert:assertFileExists file="${maven.hibernate.output.file}"/>
|
||||
|
||||
|
||||
</goal>
|
||||
|
||||
<goal name="test-hibernate-aggregate-mappings">
|
||||
<attainGoal name="jar"/>
|
||||
<attainGoal name="hibernate:aggregate-mappings"/>
|
||||
|
||||
<assert:assertFileExists file="${maven.hibernate.aggregate.output.file}"/>
|
||||
|
||||
<!-- Verify that that files from both base directories are present -->
|
||||
<util:file var="rawFile" name="${maven.hibernate.aggregate.output.file}"/>
|
||||
<x:parse var="doc" xml="${rawFile}"/>
|
||||
|
||||
<x:set var="count" select="count($doc//hibernate-mapping//class)"/>
|
||||
<assert:assertEquals expected="2" value="${count.intValue().toString()}"/>
|
||||
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
maven.hibernate.properties=src/main/hibernate.properties
|
||||
maven.hibernate.quiet=false
|
||||
maven.hibernate.quiet=false
|
||||
maven.hibernate.input.dir=${maven.build.dest},src/etc
|
||||
@ -53,97 +53,21 @@
|
||||
</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>ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.5.3-1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jelly</groupId>
|
||||
<artifactId>commons-jelly</artifactId>
|
||||
<version>20030902.160215</version>
|
||||
<url>http://jakarta.apache.org/commons/jelly/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-dbcp</groupId>
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<version>1.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>2.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.8</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
<version>1.0.b2</version>
|
||||
<url>http://xml.apache.org/xerces2-j/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<url>http://xml.apache.org/xerces2-j/</url>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>odmg</groupId>
|
||||
<artifactId>odmg</artifactId>
|
||||
<version>3.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>1.4</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
16
hibernate/src/plugin-test/src/etc/Component.hbm.xml
Normal file
16
hibernate/src/plugin-test/src/etc/Component.hbm.xml
Normal file
@ -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.Component" table="Component" >
|
||||
<id name="id" type="int" column="ID" unsaved-value="0">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<property name="name" column="NAME" type="string"/>
|
||||
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
||||
@ -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: Component.java,v 1.1 2004/07/02 07:32:53 epugh Exp $
|
||||
*/
|
||||
|
||||
public class Component {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,9 @@
|
||||
<author email="michal.maczka@dimatics.com">Michal Maczka</author>
|
||||
</properties>
|
||||
<body>
|
||||
<release version="1.2" date="in CVS">
|
||||
<release version="1.2-SNAPSHOT" date="in CVS">
|
||||
<action dev="epugh" type="add" issue="MPHIBERNATE-6" due-to="Alex Shnyderman">New aggregate-mappings goal to aggregate multiple .hbm files into one file.</action>
|
||||
<action dev="epugh" type="add" issue="MPHIBERNATE-6" due-to="Alex Shnyderman">Added multiple base directories for mapping files</action>
|
||||
<action dev="epugh" type="update">Update to hibernate-2.1.3.</action>
|
||||
</release>
|
||||
<release version="1.1" date="2004-05-15">
|
||||
|
||||
@ -35,6 +35,13 @@
|
||||
<td>
|
||||
Creates SQL DDL file from set of *.hbm.xml files
|
||||
</td>
|
||||
</tr>
|
||||
<a name="hibernate:aggregate-mappings" />
|
||||
<tr>
|
||||
<td>hibernate:aggregate-mappings</td>
|
||||
<td>
|
||||
Aggregates multiple hibernate mappings into one
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
@ -96,8 +96,8 @@
|
||||
<td>maven.hibernate.input.dir</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Used to generate the <code>url</code> value for Gump
|
||||
Indicates base directory where mapping files. It defaults
|
||||
Comma-seperated list of base directories indicating where
|
||||
mapping files are located. It defaults
|
||||
to <code>${maven.build.dest}</code>.
|
||||
</td>
|
||||
</tr>
|
||||
@ -105,7 +105,7 @@
|
||||
<td>maven.hibernate.input.includes</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Comma-separated list of patterns of Hiberante mapping files,
|
||||
Comma-separated list of patterns of Hibernate mapping files,
|
||||
which will be included during generation process.
|
||||
<br/>
|
||||
<b>Note</b>: Files are relative to
|
||||
@ -119,7 +119,7 @@
|
||||
<td>maven.hibernate.input.excludes</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Comma-separated list of patterns of Hiberante mapping files,
|
||||
Comma-separated list of patterns of Hibernate mapping files,
|
||||
which will be excluded during generation process.
|
||||
<br/>
|
||||
<b>Note</b>: Files are relative to
|
||||
@ -133,6 +133,12 @@
|
||||
<td>Yes</td>
|
||||
<td>String used to separate commands in SQL output.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.hibernate.aggregate.output.file</td>
|
||||
<td>Yes</td>
|
||||
<td>When <code>aggregate-mappings</code> is run, this file will contain the aggregated mappings</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</section>
|
||||
</body>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user