0

I want to be able to execute the build of one module, in the middle of the building of an other module, but can't find how to deal with this.

I have a project with 3 modules : dao, dbGenerator and appli. project : |- dao : hibernate dao. Needs an instance of the db to execute unit tests. |- dbGenerator : depends on dao. Its build generates the db of the appli. |- appli depends on dao : uses the db generated during build of dbGenerator.

Todays build sequence :

  1. dao (-> install), but my problem is that is uses an instance of the db to execute unit tests. So a added an instance of the db in the resources
  2. dbGenerator (-> install) : compile, then generates the db instance
  3. appli (-> install) : get the db that was generated, then build, test, package

Expected build sequence would be something like this :

  1. dao (->compile)
  2. dbGenerator (-> install)
  3. dao (test->install)
  4. appli (->install)

Thanks for your help

[Edit] to be more precise, my expectations are that dao unit tests can be executed, using the db generated by dbGenerator.

cyril
  • 1
  • 2
  • run mvn commands from a shell script is an option – Fran Montero Jul 31 '15 at 07:23
  • Not possible. The dao module will first be used if completly packaged. Create the database withou using the dao objects or better use an import.sql script and an embedded database for your unit tests. – Stefan Jul 31 '15 at 07:28
  • Why you cannot run the build sequence you expect with four different mvn commands? – Fran Montero Jul 31 '15 at 07:50
  • @FranMontero i am new with maven, and i even did not think to this solution til you mentioned it. It seems a bit heavy to use daily. Context is a small dev team that codes and build with eclipse. I will have a look to find if its possible to integrate these 4 commands in one m2e run configuration, in order to keep a build start easy/simple. tks – cyril Jul 31 '15 at 08:37
  • That is the only way i can think right know. Anyway, for me, unit testing can't depend on external resources as databases. Changing that would let you execute steps 1+3, then 2 and finally 4. – Fran Montero Jul 31 '15 at 08:51
  • This sounds like you need a separate integration test module which you should put into the integration test phase (using maven-failsafe-plugin) and appropriate configuration. Take a look into the documentation about the [build life cycle](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html). – khmarbaise Jul 31 '15 at 09:01
  • @FranMontero the logical design with all this is dao depends on the db schema, and that db schema is produced by the generator. the generator is used only at build time, so i wanted to separate it from the dao (separated code, ugly comparing to appli code, without unit tests and coverage, etc...) but using dao to make it simple / fast to evolve. Sure there a circular reference, but only at build time, not at execution one. You sequence idea has grown in my head today. there should be something that way – cyril Jul 31 '15 at 14:01
  • @khmarbaise Well i don't like the idea to separate code from tests. I know its not clear here, but i like when thinks are simple :) I have perhaps found a good way to do splitting my build in 2 steps. The first, with a specific profile, will compile dao and then generate the db. The second and main one will build all the project unless dbgenerator – cyril Jul 31 '15 at 14:11
  • Separating is a good argument but in your case these are integration tests which is a different level of view instead of unit tests. – khmarbaise Aug 01 '15 at 12:22

0 Answers0