Search code examples
mavenmaven-resources-pluginhibernate3-maven-plugin

Generate SQL-scheme and copy it to include to WAR-file: problem with plugins' dependencies


Before running integration tests I need to setup database. This include generating SQL-scheme (based on JPA-annotations), save it to file and copy it with other resources to directory which later will be used for creating war file (which will be deployed to Jetty).

So, I use following hibernate3-maven-plugin configuration for generating SQL-scheme: http://pastebin.ubuntu.com/606229/

To copy resulting hsql-scheme.sql from src/env/test/WEB-INF/classes to target/ where it will be packaged to WAR-file I use following: http://pastebin.ubuntu.com/606230/

But when I run mvn verify -P test (yes, all these code inside separate profile) I've got: http://pastebin.ubuntu.com/606231/

As you can see hibernate3:hbm2ddl does not generate any SQL-scheme and resulting file is empty (in other case we will see it on console also). And this is a problem.

The root of problem (as I understand) is because hibernate3:hbm2ddl invokes the execution of the lifecycle phase process-resources prior to executing itself.

Thanks in advance!


Solution

  • This question helped me to fix schema' creation:

    • call hibernate3:hbm2ddl at prepare-package phase instead of generate-resources

    • put result of hibernate3:hbm2ddl directly to target/${build.finalName}/WEB-INF/classes

    So, now I still have hibernate3:hbm2ddl invokes the execution of the lifecycle phase process-resources prior to executing itself warning, but file target/${build.finalName}/WEB-INF/classes/hsql-scheme.sql not empty as before.