views:

63

answers:

0

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.