MPHIBERNATE-10 maven-hibernate ignores the "config" attribute

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
epugh
2004-07-23 10:35:13 +00:00
parent 6821d442f1
commit 1328dcb910
6 changed files with 57 additions and 21 deletions

View File

@@ -44,6 +44,7 @@
<h:schema-export
properties="${maven.hibernate.properties}"
config="${maven.hibernate.config}"
quiet="${maven.hibernate.quiet}"
text="${maven.hibernate.text}"
drop="${maven.hibernate.drop}"

View File

@@ -39,7 +39,7 @@ import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
*
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: SchemaExportBean.java,v 1.5 2004/07/02 07:32:53 epugh Exp $
* @version $Id: SchemaExportBean.java,v 1.6 2004/07/23 10:35:13 epugh Exp $
*/
public class SchemaExportBean extends CommonOperationsBean
{
@@ -202,24 +202,24 @@ public class SchemaExportBean extends CommonOperationsBean
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 ();
System.out.println(urls [i]);
}
if (getConfig() == null){
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);
URLClassLoader newClassLoader =
new URLClassLoader(urls, getClass().getClassLoader());
currentThread.setContextClassLoader(newClassLoader);
}
Configuration cfg = getConfiguration();
SchemaExport schemaExport = getSchemaExport(cfg);
if (isDrop())
{
schemaExport.drop(!getQuiet(), !getText());
}
}
else
{
schemaExport.create(!getQuiet(), !getText());
@@ -238,8 +238,10 @@ public class SchemaExportBean extends CommonOperationsBean
{
Configuration cfg = new Configuration();
if (getConfig() != null)
{
cfg.configure(getConfig());
{
File f = new File(getConfig());
LOG.debug("File" + f.getAbsolutePath());
cfg.configure(f);
}
String[] files = getFileNames ();

View File

@@ -19,13 +19,15 @@
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:assert="assert"
xmlns:maven="jelly:maven"
xmlns:x="jelly:xml">
<goal name="testPlugin" prereqs="test-hibernate-schema-export,test-hibernate-aggregate-mappings">
<goal name="testPlugin" prereqs="test-hibernate-schema-export-properties,test-hibernate-aggregate-mappings">
<attainGoal name="clean"/>
</goal>
<goal name="test-hibernate-schema-export">
<goal name="test-hibernate-schema-export-properties">
<j:set var="maven.hibernate.properties" value="${basedir}/src/main/hibernate.properties" />
<attainGoal name="jar"/>
<attainGoal name="hibernate:schema-export"/>
@@ -33,7 +35,17 @@
</goal>
<goal name="test-hibernate-schema-export-configuration">
<j:set var="maven.hibernate.config" value="${basedir}/target/classes/hibernate.cfg.xml" />
<attainGoal name="jar"/>
<attainGoal name="hibernate:schema-export"/>
<assert:assertFileExists file="${maven.hibernate.output.file}"/>
</goal>
<goal name="test-hibernate-aggregate-mappings">
<j:set var="maven.hibernate.input.dir" value="${maven.build.dest},${basedir}/src/etc" />
<attainGoal name="jar"/>
<attainGoal name="hibernate:aggregate-mappings"/>

View File

@@ -1,3 +1 @@
maven.hibernate.properties=${basedir}/src/main/hibernate.properties
maven.hibernate.quiet=false
maven.hibernate.input.dir=${maven.build.dest},${basedir}/src/etc
maven.hibernate.quiet=false

View File

@@ -0,0 +1,25 @@
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- shared properties -->
<session-factory>
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">jdbc:hsqldb:.</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">0</property>
<property name="show_sql">false</property>
<property name="dialect">org.hsqldb.jdbcDriver</property>
<mapping resource="org/apache/maven/hibernate/Item.hbm.xml"/>
</session-factory>
</hibernate-configuration>

View File

@@ -2,6 +2,4 @@ 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:hsql://localhost
hibernate.connection.url jdbc:hsqldb:test
hibernate.connection.url jdbc:hsqldb:.