Hi Marco (and Ian)

The hibernate3 plugin in the Mojo Sandbox requires you to build it before using it. If this is okay for your situation, great. If it is not, here is how I got the hibernatetool hbm2ddl to work:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>process-classes</id>
            <phase>process-classes</phase>
            <configuration>
              <tasks>
                <property name="export" value="false"/>

                <mkdir dir="./target/generated-sources/schema"/>

                <taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"/>
                <hibernatetool destdir="target/generated-sources">
                  <classpath refid="maven.compile.classpath"/>

                  <annotationconfiguration
configurationfile="src/main/resources/ hibernate.cfg.xml"/>
                  <hbm2ddl drop="true"
                           create="true"
                           export="${export}"
                           outputfilename="schema/stockTracker.ddl"
                           delimiter=";" format="true"/>
                </hibernatetool>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>3.1.11</version>
          </dependency>
          <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-tools</artifactId>
            <version>3.1.0.beta4</version>
          </dependency>
          <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.1beta8</version>
          </dependency>
        </dependencies>
      </plugin>

There are a couple of things to note with the way I'm using the plugin. First, I'm using the lifecycle phase process-classes which occurs after the compile phase, I've also used compile phase which works as well. However, the issue here is hbm2ddl needs .class files not .java files, so positioning the phase to one that occurs after compilation seemed to make sense. Look here for more info: http://maven.apache.org/guides/introduction/introduction-to-the- lifecycle.html. I've also got a property "export" that if set on the command line, (mvn process-classes -Dexport=true) will cause the ddl to be generated and executed on the database. You may or may not want that. Oh yeah, I'm also using annotations, so you may need to change the <annotationconfiguration> section, but that's not a Maven thing, its a hibernatetool thing - I'm sure you already knew that too :-)

I hope this helps.

Chris


On Mar 9, 2006, at 11:42 AM, [EMAIL PROTECTED] wrote:

Marco,

There are a number of resources I've found useful in tracking down Maven
plug-ins:

Available Maven Plugins (http://maven.apache.org/plugins/index.html)
Maven Plug-in Matrix
(http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Matrix)
Mojo Maven2 Plugins Project (http://mojo.codehaus.org)
Maven2 Plugin Requests (http://jira.codehaus.org/browse/MNG, then select
'Plugin Requests' under 'Components')

There is a Hibernate3 plugin
(http://mojo.codehaus.org/hibernate3-maven-plugin/) in the Mojo Sandbox that looks like it might meet your needs, especially the hibernate3:hbm2ddl goal (http://mojo.codehaus.org/hibernate3-maven-plugin/hbm2ddl- mojo.html).


HTH,
Ian

It's better to be hated for who you are
than loved for who you are not

Ian D. Stewart
Appl Dev Analyst-Advisory, DCS Automation
JPMorganChase Global Technology Infrastructure
Phone: (614) 244-2564
Pager: (888) 260-0078



                      "Marco Mistroni"
<[EMAIL PROTECTED] To: "Maven Users List" <[email protected]>
                      com>                     cc:
Subject: Maven2 HibernatePlugin
                      03/09/2006 12:32
                      PM
                      Please respond to
                      "Maven Users
                      List"





hello,

i am looking for a Maven Hibernate Plugin for Maven2 which uses Hibernate3
for generating
sql table scripts out of Hibernate files..

does it exist? if so, where ic an download it?

thanks and regards
 marco



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to