title: Hibernate3 Maven plugin misconfiguration?
body: <p>The first time i built my project, i already knew that i will get crazy if it does not stop doing things twice and now the time has come. I have not found a solution yet or maybe i just don't know how to search for this issue.</p>
  
  <p>I have some hbm.xml files which get processed within my build process. First of all you can look at the part of my pom.xml which should do the trick.</p>
  
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;generate-xml-files&lt;/id&gt;
                      &lt;phase&gt;generate-resources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;hbm2cfgxml&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;generate-entities&lt;/id&gt;
                      &lt;phase&gt;generate-resources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;hbm2java&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;generate-schema&lt;/id&gt;
                      &lt;phase&gt;compile&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;hbm2ddl&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;components&gt;
                      &lt;component&gt;
                          &lt;name&gt;hbm2cfgxml&lt;/name&gt;
                          &lt;implementation&gt;configuration&lt;/implementation&gt;
                          &lt;outputDirectory&gt;target/classes&lt;/outputDirectory&gt;
                      &lt;/component&gt;
                      &lt;component&gt;
                          &lt;name&gt;hbm2java&lt;/name&gt;
                          &lt;implementation&gt;configuration&lt;/implementation&gt;
                          &lt;outputDirectory&gt;src/main/java&lt;/outputDirectory&gt;
                      &lt;/component&gt;
                      &lt;component&gt;
                          &lt;name&gt;hbm2ddl&lt;/name&gt;
                          &lt;implementation&gt;configuration&lt;/implementation&gt;
                          &lt;outputDirectory&gt;target/classes&lt;/outputDirectory&gt;
                      &lt;/component&gt;
                  &lt;/components&gt;
                  &lt;componentProperties&gt;
                      &lt;jdk5&gt;true&lt;/jdk5&gt;
                      &lt;packagename&gt;com.blazebit.web.cms.core.model&lt;/packagename&gt;
                      &lt;propertyfile&gt;src/main/resources/database.properties&lt;/propertyfile&gt;
                      &lt;configurationfile&gt;target/classes/hibernate.cfg.xml&lt;/configurationfile&gt;
                      &lt;!-- Tells the plugin to send the output to a file --&gt;
                      &lt;outputfilename&gt;schema.sql&lt;/outputfilename&gt;
                      &lt;!-- Pretty Format SQL Code --&gt;
                      &lt;format&gt;true&lt;/format&gt;
                      &lt;!-- Do not create tables automatically - other plug-ins will handle that --&gt;
                      &lt;export&gt;false&lt;/export&gt;
                      &lt;!-- Do not print the DDL to the console --&gt;
                      &lt;console&gt;false&lt;/console&gt;
                  &lt;/componentProperties&gt;
              &lt;/configuration&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;mysql&lt;/groupId&gt;
                      &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                      &lt;version&gt;5.0.8&lt;/version&gt;
                  &lt;/dependency&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;cglib&lt;/groupId&gt;
                      &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
                      &lt;version&gt;2.1_3&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;  
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;com.blazebit&lt;/groupId&gt;
              &lt;artifactId&gt;HibernateCfgBuilder&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;HibernateCfgBuilder&lt;/id&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;HibernateCfgBuilder&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;hbmXmlFilesDir&gt;src/main/resources/com/blazebit/web/cms/core/model/&lt;/hbmXmlFilesDir&gt;
                  &lt;configFile&gt;target/classes/hibernate.cfg.xml&lt;/configFile&gt;
                  &lt;packageName&gt;com.blazebit.web.cms.core.model&lt;/packageName&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>Now let me explain what this all should do.</p>
  
  <ul>
  <li>First thing is hbm2cfg i think, it should create a hibernate.cfg.xml</li>
  <li>Second step is my own plugin, which adds the paths to the hbm.xml files into the hibernate.cfg.xml(could not find other solutions for this issue)</li>
  <li>Third step is hbm2java which should generate the java files into my sources directory</li>
  <li>And finally hbm2ddl it should create the schema.sql for that model in the classpath</li>
  </ul>
  
  <p>Sounds pretty simple? It even works, but it seems to do some things twice or even more times and now my build takes about 2 minutes which is annoying me :/
  Could anyone give me a tip on what i could change to make this steps work?</p>