How to handle multiple database schema creation scripts with Maven?
I have an application in development that supports several databases including SQL*Server 2008, Or开发者_JAVA百科acle 10G, Oracle 11G, MYSQL 5, etc. Already within Maven I have done three things:
1) There is a profile for each database so that the system can use it for integration testing during the build.
2) Maven invokes the hibernate3 plugin to automatically generate a schema script using hbm2ddl.
3) A Hudson matrix build is set up so that integration tests are run against every database automatically.
I have noticed (with no surprise) that the script created by hbm2ddl is different depending on the database dialect.
However, when packaging the system for customers we have to manually go into the various Hudson builds and pluck the database specific scripts from there. A tedious process that I am sure will bite us at the worst possible moment!!
Is there anyway that we can have Maven automatically generate and then gather up all these database scripts so that they can be packaged along side the WAR file we ship to customers? I was thinking of the Maven assembly plugin to zip it all up, but am not sure!
Is there anyway that we can have Maven automatically generate and then gather up all these database scripts so that they can be packaged along side the WAR file we ship to customers? I was thinking of the Maven assembly plugin to zip it all up, but am not sure!
The problem is that the scripts are generated for each profile run (at least this is my understanding) and unless you package them in some kind of distinct artifacts (could be assemblies) and install/deploy them at each run, you won't be able to grab them in a subsequent step with Maven.
The alternative would be to have a module with several executions of the hbm2ddl
goal defined. But I'm afraid this will defeat the whole profile stuff.
Or you could maybe use the M2 Extra Steps Plugin to rely on Hudson and add some post-build steps to your Maven builds (not sure if this can help).
精彩评论