Index: .classpath =================================================================== RCS file: .classpath diff -N .classpath --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .classpath 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ + + + + + + + + Index: .project =================================================================== RCS file: .project diff -N .project --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .project 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ + + + maven-plugins + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + Index: hibernate/.cvsignore =================================================================== RCS file: hibernate/.cvsignore diff -N hibernate/.cvsignore --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/.cvsignore 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +target +velocity.log +maven.log +.classpath +.project Index: hibernate/plugin.jelly =================================================================== RCS file: hibernate/plugin.jelly diff -N hibernate/plugin.jelly --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/plugin.jelly 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,89 @@ + + + + + + + + + + + + + Aggregating multiple hibernate mapping into one single file + + + + + + + Exporting Hibernate Schema file + + + + + + + Updating database schema + + + + + + + Generating POJOs from hbm files + + + + + + + + + + Index: hibernate/plugin.properties =================================================================== RCS file: hibernate/plugin.properties diff -N hibernate/plugin.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/plugin.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------- +# 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. +# ------------------------------------------------------------------- + +#maven.hibernate.properties= +maven.hibernate.quiet=yes +maven.hibernate.text=no +maven.hibernate.drop=no +maven.hibernate.delimiter= +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.aggregate.output.file=${maven.hibernate.output.dir}/aggregated-mappings.hbm.xml +maven.hibernate.generated.config= +maven.hibernate.generated.input.dir=${maven.src.dir}/main +maven.hibernate.generated.output.dir=${maven.src.dir}/main +maven.hibernate.generated.input.includes=${maven.hibernate.input.includes} +maven.hibernate.generated.input.excludes=${maven.hibernate.input.excludes} Index: hibernate/project.properties =================================================================== RCS file: hibernate/project.properties diff -N hibernate/project.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/project.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ +# ------------------------------------------------------------------- +# 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. +# ------------------------------------------------------------------- + +# ------------------------------------------------------------------- +# P R O J E C T P R O P E R T I E S +# ------------------------------------------------------------------- +maven.docs.outputencoding=UTF-8 +maven.junit.fork=true Index: hibernate/project.xml =================================================================== RCS file: hibernate/project.xml diff -N hibernate/project.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/project.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,195 @@ + + + + + + ../plugin-parent/project.xml + 3 + maven-hibernate-plugin + Maven Hibernate Plug-in + 1.3-SNAPSHOT + + Work with Hibernate classes + http://maven.apache.org/reference/plugins/hibernate/ + http://jira.codehaus.org/browse/MPHIBERNATE + /www/maven.apache.org/reference/plugins/hibernate/ + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/hibernate/ + scm:cvs:ext:${maven.username}@cvs.apache.org:/home/cvs:maven-plugins/hibernate/ + http://cvs.apache.org/viewcvs/maven-plugins/hibernate/ + + + + 1.0 + 1.0 + MAVEN_HIBERNATE_1_0 + + + 1.1 + 1.1 + MAVEN_HIBERNATE_1_1 + + + 1.2 + 1.2 + MAVEN_HIBERNATE_1_2 + + + + + Michal Maczka + michal + michal.maczka@dimatics.com + Dimatics + + Java Developer + + +1 + + + Eric Pugh + epugh + epugh@opensourceconnections.com + OpenSource Connections + + Java Developer + + + + Felipe Leme + felipeal + maven@felipeal.net + Falcon Informatica + + Java Developer + + -3 + + + + + Alex Shneyderman + as851@columbia.edu + + + + + hibernate + hibernate + 2.1.3 + jar + + + hibernate + hibernate-tools + 2.1.3 + jar + + + jdom + jdom + 1.0 + jar + + + ant + ant + 1.5.3-1 + jar + + + commons-jelly + commons-jelly + 20030902.160215 + http://jakarta.apache.org/commons/jelly/ + + + commons-lang + commons-lang + 2.0 + jar + + + commons-beanutils + commons-beanutils + 1.6.1 + jar + + + commons-dbcp + commons-dbcp + 1.1 + jar + + + commons-collections + commons-collections + 2.1 + jar + + + commons-logging + commons-logging + 1.0.3 + jar + + + commons-pool + commons-pool + 1.1 + jar + + + log4j + log4j + 1.2.8 + jar + + + xml-apis + xml-apis + 1.0.b2 + http://xml.apache.org/xerces2-j/ + + + xerces + xerces + 2.4.0 + http://xml.apache.org/xerces2-j/ + + + odmg + odmg + 3.0 + jar + + + cglib + cglib + 2.0.2 + jar + + + dom4j + dom4j + 1.4 + jar + + + Index: hibernate/src/main/org/apache/maven/hibernate/HibernateEntityResolver.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/HibernateEntityResolver.java diff -N hibernate/src/main/org/apache/maven/hibernate/HibernateEntityResolver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/HibernateEntityResolver.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,106 @@ +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. + * ==================================================================== + */ + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * A class to resolve external entity definitions for j2ee artifacts. + * Based on the J2EEEntityResolver from the J2EE plugin + * + * @author eric pugh + * @version $Id: HibernateEntityResolver.java,v 1.1 2004/07/23 11:25:25 epugh Exp $ + */ +public class HibernateEntityResolver implements EntityResolver +{ + /** map of ids to resource names */ + private Map idToResource = new HashMap(); + + /** log for debug output */ + private static final Log LOG = LogFactory.getLog(HibernateEntityResolver.class); + + /** list of j2ee dtds that are being made available */ + public static final String[] HIBERNATE_DTDS = new String[] { + "-//Hibernate/Hibernate Mapping DTD 2.0//EN" + }; + public static final String[] HIBERNATE_RESOURCES = new String[] { + "/plugin-resources/hibernate-mapping-2.0.dtd" + }; + + /** Creates a new instance of EntityResolver */ + public HibernateEntityResolver() + { + for (int i = 0; i < HIBERNATE_DTDS.length; i++) { + idToResource.put(HIBERNATE_DTDS[i], HIBERNATE_RESOURCES[i]); + } + } + + /** resolve the entity given by the provided Ids + * @param publicId the public id of the entity + * @param systemId the 'system location' (typically a URL) of the entity + * @return an {@link InputSource input source} for retrieval of the entity + * @throws IOException when an I/O error occurs retrieving the entity + * @throws SAXException if there are any problems + */ + public InputSource resolveEntity(String publicId, String systemId) throws + SAXException, IOException + { + LOG.debug("resolving entity with publicId='" + publicId + ", systemId='" + systemId + "'"); + if (publicId != null) + { + String resource = (String) idToResource.get(publicId); + LOG.debug("resource found in map ='" + resource + "'" ); + if (resource != null) + { + InputStream in = getClass().getResourceAsStream(resource); + LOG.debug("input stream ='" + in + "'" ); + if (in != null) + { + return new InputSource(in); + } + } + } + return null; + } + + /** Getter for publicId to resource name map. + * @return Value of property idToResource. + */ + protected Map getIdToResource() + { + return idToResource; + } + + /** Setter for publicId to resource name map. + * @param idToResource New value of property idToResource. + */ + protected void setIdToResource(Map idToResource) + { + this.idToResource = idToResource; + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/CodeGenerationBean.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/CodeGenerationBean.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/CodeGenerationBean.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/CodeGenerationBean.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +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 net.sf.hibernate.tool.hbm2java.CodeGenerator; + +/** + * @author Paul Kearney + * @version $Id$ + */ +public class CodeGenerationBean extends CommonOperationsBean { + + private static final String OUTPUT_SWITCH = "--output="; + + private String outputdir = null; + + public void execute() { + + // Construct output directory argument + StringBuffer switchArg= new StringBuffer(); + switchArg.append(OUTPUT_SWITCH).append(getOutputdir()); + + // Get list of files that are to be used to generate POJOs + final String[] files = getFileNames(); + + // Require new array to combine command args with hbm files array + String[] args = new String[files.length + 1]; + // Add command arg to new array + args[0] = switchArg.toString(); + // Copy list of hbm files to new array + System.arraycopy(files, 0, args, 1, files.length); + + // Generate POJOs + CodeGenerator generator = new CodeGenerator(); + generator.main(args); + + } + + public String getOutputdir() { + return this.outputdir; + } + + public void setOutputdir(String outputdir) { + this.outputdir = outputdir; + } +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/CommonOperationsBean.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/CommonOperationsBean.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/CommonOperationsBean.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/CommonOperationsBean.java 1 Jan 1970 00:00:00 -0000 @@ -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 Alex Shneyderman + * @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.debug(" 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]); + } + + + + +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/MappingsAggregatorBean.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/MappingsAggregatorBean.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/MappingsAggregatorBean.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/MappingsAggregatorBean.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,114 @@ +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.apache.maven.hibernate.HibernateEntityResolver; +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 Alex Shneyderman + * @since $Id: MappingsAggregatorBean.java,v 1.2 2004/07/23 11:25:24 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); + writer.setEntityResolver(new HibernateEntityResolver()); + //writer.setResolveEntityRefs(false); + Document finalDoc = DocumentHelper.createDocument(); + Element rootHM = null; + for(int i = 0; i < files.length; i++) + { + SAXReader reader = new SAXReader(false); + reader.setEntityResolver(new HibernateEntityResolver()); + //reader.setIncludeExternalDTDDeclarations(false); + //reader.setIncludeExternalDTDDeclarations(false); + 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; + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaBeanBase.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaBeanBase.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/SchemaBeanBase.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/SchemaBeanBase.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,235 @@ +package org.apache.maven.hibernate.beans; + +/* ==================================================================== + * 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. + * ==================================================================== + */ + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +import net.sf.hibernate.HibernateException; +import net.sf.hibernate.cfg.Configuration; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * Base class for Beans which serve as Proxy To Hibernate API + *
+ * + * @author Michal Maczka + * @author Felipe Leme + * @version $Id: SchemaBeanBase.java,v 1.1 2004/11/06 21:50:38 felipeal Exp $ + */ +public abstract class SchemaBeanBase extends CommonOperationsBean +{ + + private String properties = null; + private String config = null; + private boolean quiet = false; + private boolean text = false; + + protected static final Log LOG = LogFactory.getLog(MappingsAggregatorBean.class); + + + + /** + * @return + */ + public boolean getQuiet() + { + return quiet; + } + + /** + * @return + */ + public boolean getText() + { + return text; + } + + /** + * @param b + */ + public void setQuiet(boolean b) + { + quiet = b; + } + + /** + * @param b + */ + public void setText(boolean b) + { + text = b; + } + + /** + * @return + */ + public String getConfig() + { + return config; + } + + /** + * @return + */ + public String getProperties() + { + return properties; + } + + /** + * @param string + */ + public void setConfig(String string) + { + config = string; + } + + /** + * @param string + */ + public void setProperties(String string) + { + properties = string; + } + + /** + * + * Hibernate requires that + * Java classes (beans) are accesible on the + * classpath. As they are not in plugin classpath + * we have to take care about. + * To assure that we have them visible for plugin + * classloader + * we will make temporay change to context classloader + * which will be restored when method terminates. + * + */ + public void execute() throws Exception + { + + Thread currentThread = Thread.currentThread(); + ClassLoader oldClassLoader = currentThread.getContextClassLoader(); + try + { + File [] baseDirs = getBaseDirs (); + URL [] urls = new URL [baseDirs.length]; + for (int i = 0; i < urls.length; i++) { + urls [i] = baseDirs [i].toURL (); + } + + URLClassLoader newClassLoader = + new URLClassLoader(urls, getClass().getClassLoader()); + currentThread.setContextClassLoader(newClassLoader); + + Configuration cfg = getConfiguration(); + executeSchema( cfg ); + + } + finally + { + currentThread.setContextClassLoader(oldClassLoader); + } + } + + /** + * Method that does the real job + */ + protected abstract void executeSchema(Configuration cfg) throws Exception; + + /** + * + */ + private Configuration getConfiguration() throws HibernateException + { + Configuration cfg = new Configuration(); + if (getConfig() != null) + { + File f = new File(getConfig()); + LOG.debug("Hibernate Configuration File: " + f.getAbsolutePath()); + cfg.configure(f); + } + + String[] files = getFileNames (); + for (int i = 0; i < files.length; i++) + { + String filename = files[i]; + if (filename.endsWith(".jar")) + { + cfg.addJar(filename); + } + else + { + cfg.addFile(filename); + } + } + return cfg; + } + + private String schemaOutputFile = null; + private String delimiter = null; + + + + /** + * @return + */ + public String getSchemaOutputFile() { + return schemaOutputFile; + } + + /** + * @return + */ + public String getOutputFile() { + return schemaOutputFile; + } + + /** + * @return + */ + public String getDelimiter() { + return delimiter; + } + + /** + * @param string + */ + public void setSchemaOutputFile(String string) { + schemaOutputFile = string; + } + + /** + * @param string + */ + public void setOutputFile(String string) { + schemaOutputFile = string; + } + + /** + * @param string + */ + public void setDelimiter(String string) { + delimiter = string; + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaExportBean.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaExportBean.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/SchemaExportBean.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/SchemaExportBean.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,80 @@ +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.FileInputStream; +import java.util.Properties; + +import net.sf.hibernate.cfg.Configuration; +import net.sf.hibernate.tool.hbm2ddl.SchemaExport; + +/** + * + * The Bean which serves as Proxy To Hibernate API + *
+ * + * @author Michal Maczka + * @version $Id: SchemaExportBean.java,v 1.8 2004/11/06 21:50:38 felipeal Exp $ + */ +public class SchemaExportBean extends SchemaBeanBase +{ + + private boolean drop = false; + + /** + * @return + */ + public boolean isDrop() + { + return drop; + } + + /** + * @param b + */ + public void setDrop(boolean b) + { + drop = b; + } + + protected void executeSchema(Configuration cfg) throws Exception { + SchemaExport schemaExport = null; + if (getProperties() == null) + { + schemaExport = new SchemaExport(cfg); + } + else + { + Properties properties = new Properties(); + properties.load(new FileInputStream(getProperties())); + schemaExport = new SchemaExport(cfg, properties); + } + LOG.debug("Output file:" + getOutputFile()); + schemaExport.setOutputFile(getOutputFile()); + schemaExport.setDelimiter(getDelimiter()); + if (isDrop()) + { + schemaExport.drop(!getQuiet(), !getText()); + } + else + { + schemaExport.create(!getQuiet(), !getText()); + } + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaUpdateBean.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/beans/SchemaUpdateBean.java diff -N hibernate/src/main/org/apache/maven/hibernate/beans/SchemaUpdateBean.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/beans/SchemaUpdateBean.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,52 @@ +package org.apache.maven.hibernate.beans; + +/* ==================================================================== + * 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. + * ==================================================================== + */ + +import java.io.FileInputStream; +import java.util.Properties; + +import net.sf.hibernate.cfg.Configuration; +import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate; + +/** + * + * The Bean which serves as Proxy To Hibernate SchemaUpdate + *
+ * + * @author Felipe Leme + * @version $Id: SchemaUpdateBean.java,v 1.1 2004/11/06 21:51:31 felipeal Exp $ + */ +public class SchemaUpdateBean extends SchemaBeanBase +{ + + protected void executeSchema(Configuration cfg) throws Exception { + SchemaUpdate schemaUpdate = null; + if (getProperties() == null) + { + schemaUpdate = new SchemaUpdate(cfg); + } + else + { + Properties properties = new Properties(); + properties.load(new FileInputStream(getProperties())); + schemaUpdate = new SchemaUpdate(cfg, properties); + } + schemaUpdate.execute( !getQuiet(), !getText() ); + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/AggregateMappingsTag.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/AggregateMappingsTag.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/AggregateMappingsTag.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/AggregateMappingsTag.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,93 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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 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); + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/CodeGenerationTag.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/CodeGenerationTag.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/CodeGenerationTag.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/CodeGenerationTag.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,99 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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 org.apache.commons.jelly.JellyTagException; +import org.apache.commons.jelly.MissingAttributeException; +import org.apache.commons.jelly.TagSupport; +import org.apache.commons.jelly.XMLOutput; +import org.apache.maven.hibernate.beans.CodeGenerationBean; + +/** + * @author Paul Kearney + * @version $Id$ + */ +public class CodeGenerationTag extends TagSupport { + + private CodeGenerationBean bean = new CodeGenerationBean(); + + /** + * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput) + */ + public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException { + + execute(); + } + + /** + * + */ + protected void execute() throws JellyTagException + { + try { + bean.execute(); + } catch (Exception e) { + String msg = "Code generation operation failed"; + throw new JellyTagException(msg, e); + } + } + + public String getBasedir() + { + return bean.getBasedir(); + } + + public String getExcludes() + { + return bean.getExcludes(); + } + + public String getIncludes() + { + return bean.getIncludes(); + } + + public String getOutputdir() + { + return bean.getOutputdir(); + } + + public void setBasedir(String string) + { + bean.setBasedir(string); + } + + public void setExcludes(String string) + { + bean.setExcludes(string); + } + + public void setIncludes(String string) + { + bean.setIncludes(string); + } + + public void setOutputdir(String dir) + { + bean.setOutputdir(dir); + } + + public String toString() + { + return bean.toString(); + } +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/HibernateTagLibrary.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/HibernateTagLibrary.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/HibernateTagLibrary.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/HibernateTagLibrary.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,42 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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 org.apache.commons.jelly.tags.core.CoreTagLibrary; + + +/** + * Hibernate tag library. + * + * @author Michal Maczka + * @version $Id: HibernateTagLibrary.java,v 1.4 2004/11/06 21:52:23 felipeal Exp $ + */ +public class HibernateTagLibrary extends CoreTagLibrary +{ + /** + * Create an instance of the {@link HibernateTagLibrary}, registering related + * tag libraries + */ + public HibernateTagLibrary() + { + registerTag( "schema-export", SchemaExportTag.class ); + registerTag( "schema-update", SchemaUpdateTag.class ); + registerTag( "aggregate-mappings", AggregateMappingsTag.class ); + registerTag( "hbm-code-generation", CodeGenerationTag.class ); + } +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaExportTag.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaExportTag.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaExportTag.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaExportTag.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,66 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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 org.apache.maven.hibernate.beans.SchemaExportBean; + +/** + * + * Jelly tag which delagates all calls to {@link SchemaExportBean} + * + * @author Michal Maczka + * @version $Id: SchemaExportTag.java,v 1.5 2004/11/06 21:50:38 felipeal Exp $ + */ +public class SchemaExportTag extends SchemaTagBase +{ + + public SchemaExportTag() { + super( new SchemaExportBean() ); + } + + public void setDrop(boolean b) + { + ((SchemaExportBean) bean).setDrop(b); + } + + public void setOutputFile(String string) + { + bean.setOutputFile(string); + } + + public void setDelimiter(String delimiter) + { + bean.setDelimiter(delimiter); + } + + public boolean isDrop() + { + return ((SchemaExportBean) bean).isDrop(); + } + + public String getOutputFile() + { + return bean.getOutputFile(); + } + + public String getDelimiter() + { + return bean.getDelimiter(); + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaTagBase.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaTagBase.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaTagBase.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaTagBase.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,199 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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. + * ==================================================================== + */ + +import org.apache.commons.jelly.JellyTagException; +import org.apache.commons.jelly.TagSupport; +import org.apache.commons.jelly.XMLOutput; +import org.apache.maven.hibernate.beans.SchemaBeanBase; + +/** + * + * Base class for Jelly tags that uses Hibernate's Schema classes + * + * @author Michal Maczka + * @author Felipe Leme + * @version $Id: SchemaTagBase.java,v 1.1 2004/11/06 21:50:38 felipeal Exp $ + */ +public abstract class SchemaTagBase extends TagSupport +{ + + protected final SchemaBeanBase bean; + + protected SchemaTagBase( SchemaBeanBase b ) { + bean = b; + } + + /** + * + */ + protected void execute() throws JellyTagException + { + try + { + bean.execute(); + } + catch (Exception e) + { + String msg = "Schema operation failed"; + throw new JellyTagException(msg, e); + } + + } + + /** + * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput) + */ + public void doTag(XMLOutput arg0) throws JellyTagException + { + execute(); + } + + /** + * @return + */ + public boolean getText() + { + return bean.getText(); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + public String toString() + { + return bean.toString(); + } + + /** + * @return + */ + public boolean getQuiet() + { + return bean.getQuiet(); + } + + /** + * @param string + */ + public void setExcludes(String string) + { + bean.setExcludes(string); + } + + /** + * @param string + */ + public void setIncludes(String string) + { + bean.setIncludes(string); + } + + /** + * @return + */ + public String getExcludes() + { + return bean.getExcludes(); + } + + /** + * @param string + */ + public void setConfig(String string) + { + bean.setConfig(string); + } + + /** + * @return + */ + public String getIncludes() + { + return bean.getIncludes(); + } + + /** + * @return + */ + public String getBasedir() + { + return bean.getBasedir(); + } + + /** + * @return + */ + public String getProperties() + { + return bean.getProperties(); + } + + /** + * @return + */ + public String getConfig() + { + return bean.getConfig(); + } + + /** + * @param b + */ + public void setText(boolean b) + { + bean.setText(b); + } + + /** + * @param string + */ + public void setBasedir(String string) + { + bean.setBasedir(string); + } + + /** + * @param b + */ + public void setQuiet(boolean b) + { + bean.setQuiet(b); + } + + /** + * @param string + */ + public void setProperties(String string) + { + bean.setProperties(string); + } + + + /** + */ + public String getSchemaOutputFile() { + return bean.getSchemaOutputFile(); + } + /** + */ + public void setSchemaOutputFile(String string) { + bean.setSchemaOutputFile(string); + } + +} Index: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaUpdateTag.java =================================================================== RCS file: hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaUpdateTag.java diff -N hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaUpdateTag.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/main/org/apache/maven/hibernate/jelly/SchemaUpdateTag.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,36 @@ +package org.apache.maven.hibernate.jelly; + +/* ==================================================================== + * 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. + * ==================================================================== + */ + +import org.apache.maven.hibernate.beans.SchemaUpdateBean; + +/** + * + * Jelly tag which delagates all calls to {@link SchemaUpdateBean} + * + * @author Felipe Leme + * @version $Id: SchemaUpdateTag.java,v 1.1 2004/11/06 21:51:31 felipeal Exp $ + */ +public class SchemaUpdateTag extends SchemaTagBase +{ + + public SchemaUpdateTag() { + super( new SchemaUpdateBean() ); + } + +} Index: hibernate/src/plugin-resources/hibernate-mapping-2.0.dtd =================================================================== RCS file: hibernate/src/plugin-resources/hibernate-mapping-2.0.dtd diff -N hibernate/src/plugin-resources/hibernate-mapping-2.0.dtd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-resources/hibernate-mapping-2.0.dtd 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,536 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: hibernate/src/plugin-test/.cvsignore =================================================================== RCS file: hibernate/src/plugin-test/.cvsignore diff -N hibernate/src/plugin-test/.cvsignore --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/.cvsignore 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +target +.classpath +.project Index: hibernate/src/plugin-test/maven.xml =================================================================== RCS file: hibernate/src/plugin-test/maven.xml diff -N hibernate/src/plugin-test/maven.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/maven.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: hibernate/src/plugin-test/project.properties =================================================================== RCS file: hibernate/src/plugin-test/project.properties diff -N hibernate/src/plugin-test/project.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/project.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1 @@ +maven.hibernate.quiet=false Index: hibernate/src/plugin-test/project.xml =================================================================== RCS file: hibernate/src/plugin-test/project.xml diff -N hibernate/src/plugin-test/project.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/project.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,109 @@ + + + + + + 3 + test-maven-hibernate-plugin + Test project for Maven Hibernate + maven + 1.0-SNAPSHOT + + Apache Software Foundation + http://www.apache.org/ + http://maven.apache.org/images/jakarta-logo-blue.gif + + 2001 + org.apache.maven + http://maven.apache.org/images/maven.jpg + Test for Maven Hibernate plugin + Test for Maven Hibernate plugin + http://maven.apache.org/reference/plugins/hibernate/ + /www/maven.apache.org/reference/plugins/hibernate/ + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/hibernate/src/plugin-test + http://cvs.apache.org/viewcvs/maven-plugins/hibernate/src/plugin-test + + + + Eric Pugh + epugh + epugh@opensourceconnections.com + OpenSource Connections + + Developer + + + + + + + + commons-jelly + commons-jelly-tags-xml + 20030211.142705 + http://jakarta.apache.org/commons/jelly/libs/xml/ + + + + + hsqldb + hsqldb + 1.7.1 + jar + + + + hibernate + hibernate + 2.1.3 + jar + + + cglib + cglib + 2.0.2 + jar + + + dom4j + dom4j + 1.4 + jar + + + commons-lang + commons-lang + 2.0 + jar + + + + + src/main + + + src/main + + **/*.xml + + + + + Index: hibernate/src/plugin-test/src/etc/Component.hbm.xml =================================================================== RCS file: hibernate/src/plugin-test/src/etc/Component.hbm.xml diff -N hibernate/src/plugin-test/src/etc/Component.hbm.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/etc/Component.hbm.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + Index: hibernate/src/plugin-test/src/main/hibernate.cfg.xml =================================================================== RCS file: hibernate/src/plugin-test/src/main/hibernate.cfg.xml diff -N hibernate/src/plugin-test/src/main/hibernate.cfg.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/hibernate.cfg.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,25 @@ + + + + + + + + + + org.hsqldb.jdbcDriver + jdbc:hsqldb:. + sa + + 0 + false + net.sf.hibernate.dialect.HSQLDialect + + + + + + Index: hibernate/src/plugin-test/src/main/hibernate.properties =================================================================== RCS file: hibernate/src/plugin-test/src/main/hibernate.properties diff -N hibernate/src/plugin-test/src/main/hibernate.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/hibernate.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +hibernate.dialect net.sf.hibernate.dialect.HSQLDialect +hibernate.connection.driver_class org.hsqldb.jdbcDriver +hibernate.connection.username sa +hibernate.connection.password +hibernate.connection.url jdbc:hsqldb:. Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Component.java =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Component.java diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Component.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Component.java 1 Jan 1970 00:00:00 -0000 @@ -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 Eric Pugh + * + * @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; + } +} Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/ExcludeItem.hbm.xml =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/ExcludeItem.hbm.xml diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/ExcludeItem.hbm.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/ExcludeItem.hbm.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ + + + + + + + + + + + Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/IAuditable.java =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/IAuditable.java diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/IAuditable.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/IAuditable.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,27 @@ +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. + * ==================================================================== + */ + +/** + * @author Paul Kearney + * @version $Id$ + */ +public interface IAuditable { + + // used for testing maven.hibernate.generated.config property +} Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.hbm.xml =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.hbm.xml diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.hbm.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.hbm.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.java =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.java diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Item.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,47 @@ +package org.apache.maven.hibernate; + +import java.io.Serializable; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** @author Hibernate CodeGenerator */ +public class Item implements Serializable { + + /** identifier field */ + private int id; + + /** nullable persistent field */ + private String name; + + /** full constructor */ + public Item(String name) { + this.name = name; + } + + /** default constructor */ + public Item() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String toString() { + return new ToStringBuilder(this) + .append("id", getId()) + .toString(); + } + +} Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Message.hbm.xml =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Message.hbm.xml diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Message.hbm.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/Message.hbm.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ + + + + + + + + + + + + + Index: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/UserType.java =================================================================== RCS file: hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/UserType.java diff -N hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/UserType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/plugin-test/src/main/org/apache/maven/hibernate/UserType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,39 @@ +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 Paul Kearney + * + * @version $Id$ + */ +public class UserType { + + private Long field; + + + + public Long getField() { + return field; + } + public void setField(Long field) { + this.field = field; + } +} Index: hibernate/src/test/org/apache/maven/hibernate/HibernateEntityResolverTest.java =================================================================== RCS file: hibernate/src/test/org/apache/maven/hibernate/HibernateEntityResolverTest.java diff -N hibernate/src/test/org/apache/maven/hibernate/HibernateEntityResolverTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/src/test/org/apache/maven/hibernate/HibernateEntityResolverTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,80 @@ +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. + * ==================================================================== + */ + +import junit.framework.TestCase; + +/** + * Test cases for the {@link HibernateEntityResolver}. Based heavily + * on J2EEEntityResolver. + * + * @author Eric Pugh + * @version $Id: HibernateEntityResolverTest.java,v 1.1 2004/07/23 11:25:24 epugh Exp $ + */ +public class HibernateEntityResolverTest extends TestCase +{ + + /** instance for unit testing */ + private HibernateEntityResolver instance; + /** + * Creates a new instance of J2EEEntityResolverTest + * @param testName the name of the test + */ + public HibernateEntityResolverTest(String testName) + { + super(testName); + } + + /** + * Initialize per test data + * @throws Exception when there is an unexpected problem + */ + public void setUp() throws Exception + { + instance = new HibernateEntityResolver(); + } + + /** + * Test that all public ids are available and being found + */ + public void testAllAvailable() + { + assertNotNull("id to resource map not available", instance.getIdToResource()); + int numDTDs = HibernateEntityResolver.HIBERNATE_DTDS.length; + assertEquals("wrong number of entries", numDTDs, instance.getIdToResource().size()); + for (int i = 0; i < numDTDs; i++) + { + assertNotNull("Can't find resource for publicId", + instance.getIdToResource().get(HibernateEntityResolver.HIBERNATE_DTDS[i])); + } + } + + /** + * Test that the resolver is getting resources locally + */ + public void testResolvingLocally() throws Exception + { + int numDTDs = HibernateEntityResolver.HIBERNATE_DTDS.length; + for (int i = 0; i < numDTDs; i++) + { + String publicId = HibernateEntityResolver.HIBERNATE_DTDS[i]; + assertNotNull("Can't find resource for publicId " + publicId, + instance.resolveEntity(publicId, null)); + } + } +} Index: hibernate/xdocs/.cvsignore =================================================================== RCS file: hibernate/xdocs/.cvsignore diff -N hibernate/xdocs/.cvsignore --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/.cvsignore 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1 @@ +stylesheets Index: hibernate/xdocs/changes.xml =================================================================== RCS file: hibernate/xdocs/changes.xml diff -N hibernate/xdocs/changes.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/changes.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,52 @@ + + + + + + + Changes + Michal Maczka + + + + Added new goal hibernate:hbm-code-generation + Added new goal hibernate:schema-update + plugin:test fails without a network connection + + + maven-hibernate ignores the "config" attribute + maven-hibernate needs cglib when sending SQL directly to the database + Unit tests only functioned from the /src/plugin-test directory. plugin:test fails + New aggregate-mappings goal to aggregate multiple .hbm files into one file. + Added multiple base directories for mapping files + Update to hibernate-2.1.3. + + + Fix class not found exception by using correct base class loader. + + + Update to hibernate-2.0.3. Add delimiter property to schema-export tag + update to commons-jelly-20030902.160215 + Upgrade to dom4j 1.4 + Upgrade to dom4j 1.4-dev-8 + Upgrade to commons-logging 1.0.3 + Initial plugin created + + + Index: hibernate/xdocs/goals.xml =================================================================== RCS file: hibernate/xdocs/goals.xml diff -N hibernate/xdocs/goals.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/goals.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,63 @@ + + + + + + + Hibernate Plugin Goals + Michal Maczka + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
GoalDescription
hibernate:schema-export + Creates SQL DDL file and generates the database schema from set of *.hbm.xml files +
hibernate:schema-update + Updates the database schema based on the set of *.hbm.xml files +
hibernate:aggregate-mappings + Aggregates multiple hibernate mappings into one +
hibernate:hbm-code-generation + Generates Java implementation classes from set of *.hbm.xml files +
+
+ +
Index: hibernate/xdocs/index.xml =================================================================== RCS file: hibernate/xdocs/index.xml diff -N hibernate/xdocs/index.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/index.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ + + + + + + + Maven Hibernate Plug-in + Michal Maczka + + + +
+

+ This plugin provides easy integration with + Hibernate 2.x for your project. +
+ For the moment the functionality is very limited. +

+
+ + Index: hibernate/xdocs/navigation.xml =================================================================== RCS file: hibernate/xdocs/navigation.xml diff -N hibernate/xdocs/navigation.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/navigation.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ + + + + + + Maven Hibernate Plugin + + + + + + + + + + + + Index: hibernate/xdocs/properties.xml =================================================================== RCS file: hibernate/xdocs/properties.xml diff -N hibernate/xdocs/properties.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ hibernate/xdocs/properties.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,183 @@ + + + + + + + Hibernate Settings + Michal Maczka + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PropertyOptional?Description
maven.hibernate.propertiesNo + The location of Hibernate configuration file + (Java properties file). This file is also set in the + runtime by Hibernate for configuring Hibernate Session, + so it's better to keep it separately from the project's + configuration files like + project.properties etc. +
+ For description of the properties take a look + at Hibernate User Guide +
maven.hibernate.quietYes + Controls verbosity of the plugin. + Default is set to yes +
maven.hibernate.textYes + It defaults to no. If set to true, then the + generated SQL will be output only to the filesystem, not + inserted into the database. +
maven.hibernate.dropYes + Indicates whether to drop to generate just a drop table script. +
+ It defaults to no +
maven.hibernate.delimiterYesString used to separate commands in SQL output.
maven.hibernate.output.dirYes + The location of the directory where DDL SQL schema will + be generated by schema-export goal. It defaults to + ${maven.build.dir}/schema +
maven.hibernate.output.fileYes + The name of the file which will be created by schema-export + goal. It defaults to + ${maven.hibernate.output.dir}/${maven.final.name}-schema.sql. +
maven.hibernate.input.dirYes + Comma-seperated list of base directories indicating where + mapping files are located. It defaults + to ${maven.build.dest}. +
maven.hibernate.input.includesYes + Comma-separated list of patterns of Hibernate mapping files, + which will be included during generation process. +
+ Note: Files are relative to + ${maven.hibernate.input.dir}. +
+ By defaults all files are included: + **/*.hbm.xml. +
maven.hibernate.input.excludesYes + Comma-separated list of patterns of Hibernate mapping files, + which will be excluded during generation process. +
+ Note: Files are relative to + ${maven.hibernate.input.dir}. +
+ By default no files are excluded. +
maven.hibernate.aggregate.output.fileYesWhen aggregate-mappings is run, this file will contain the aggregated mappings
maven.hibernate.generated.input.dirYesComma-seperated list of base directories indicating where mapping files are located. + When hbm code generation is run, the hbm files used to generate the Java files + should be located in these directories. It defaults to + ${maven.src.dir}/main. +
maven.hibernate.generated.input.excludesYes + Comma-separated list of patterns of Hibernate mapping files, + which will be excluded during generation process. +
+ Note: Files are relative to + ${maven.hibernate.generated.input.dir}. +
+ By default no files are excluded. +
maven.hibernate.generated.input.includesYes + Comma-separated list of patterns of Hibernate mapping files, + which will be included during generation process. +
+ Note: Files are relative to + ${maven.hibernate.generated.input.dir}. +
+ By defaults all files are included: + **/*.hbm.xml. +
maven.hibernate.generated.output.dirYesWhen hbm code generation is run, the generated Java files will be placed in + this directory. It defaults to + ${maven.src.dir}/main.
+
+ +
Index: plugin-parent/project.xml =================================================================== RCS file: plugin-parent/project.xml diff -N plugin-parent/project.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugin-parent/project.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,198 @@ + + + + + + + 3 + plugin-parent + Maven Plugins + maven + 1.0 + + Apache Software Foundation + http://www.apache.org/ + http://maven.apache.org/images/apache-maven-project.png + + 2001 + org.apache.maven + http://maven.apache.org/images/maven.gif + + http://jira.codehaus.org/browse/MAVEN + maven.apache.org + /www/maven.apache.org/reference/plugins/optional/ + www.apache.org + /www/www.apache.org/dist/java-repository/ + + + + + Maven User List + users-subscribe@maven.apache.org + users-unsubscribe@maven.apache.org + http://nagoya.apache.org/eyebrowse/SummarizeList?listName=users@maven.apache.org + + + Maven Developer List + dev-subscribe@maven.apache.org + dev-unsubscribe@maven.apache.org + http://nagoya.apache.org/eyebrowse/SummarizeList?listName=dev@maven.apache.org + + + + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/ + http://cvs.apache.org/viewcvs/maven-plugins/ + + + + + dIon Gillard + dion + dion@multitask.com.au + Multitask Consulting + + Java Developer + + +10 + + + Vincent Massol + vmassol + vmassol@pivolis.com + Pivolis + + Java Developer + + +1 + + + Eric Pugh + epugh + epugh@upstate.com + Upstate + + Java Developer + + + + James Strachan + jstrachan + james_strachan@yahoo.co.uk + Spiritsoft + + Java Developer + + + + Emmanuel Venisse + evenisse + emmanuel@venisse.net + + + Java Developer + + +1 + + + Jason van Zyl + jvanzyl + jason@zenplex.com + Zenplex + + Architect + Release Manager + + + + Brett Porter + brett + brett@apache.org + f2 network + + Developer + + +10 + + + Felipe Leme + felipeal + maven@felipeal.net + Falcon Informatica + + Java Developer + Jelly Developer + + -3 + + + + + src/main + src/test + dev@maven.apache.org + + + + **/*Test.java + + + + + + .. + META-INF + + NOTICE.txt + + + + src/plugin-resources + plugin-resources + + + . + + plugin.jelly + plugin.properties + project.properties + project.xml + + + + + + + maven-changes-plugin + maven-changelog-plugin + maven-file-activity-plugin + maven-developer-activity-plugin + maven-tasklist-plugin + maven-linkcheck-plugin + maven-javadoc-plugin + maven-jxr-plugin + maven-jdepend-plugin + maven-checkstyle-plugin + maven-junit-report-plugin + maven-pmd-plugin + maven-simian-plugin + maven-faq-plugin + + +