I am setting up maven to take annotated java classes and produce some DDL which varies depending on the database. Is there a better way to do this? It seems like I should be able to filter the input to the hbm2ddl plugin (as part of a pipeline) rather than tell it to operate on the output of resource filtering (which I then must filter out of my final jar).
I am filtering my hibernate.cfg.xml file to substitute environment properties based on the local developer’s setup:
<build>
<filters>
<filter>${user.home}/datamodel-build.properties</filter>
</filters>
<resources><resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource></resources>
</build>
Then I run hbm2ddl on the output
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
...
<configuration>
<componentProperties>
<configurationfile>target/classes/com/myOrg/datamodel/hibernate.cfg.xml</configurationfile>
</plugin>
I then must filter out the hibernate.cfg.xml from my production jar since I don’t want to ship anything related to my internal dev environment.
I have this same issue and here is how I solved it. I use have a separate database.properties file that holds the connection details and I don’t filter any of my XML files.
This seperate database.properties file gets filtered, but since it is a test resource located in
/src/main/testit doesn’t get put into the final artifact. I then tell hbm2ddl where to find it as follows:Hope it helps anyway….