Question

I have a multi-module maven project structured in something like this:

parent
   |
   |-presentation
   |+services
   |    |-services-api
   |    |-services-impl
   |+data-access
   |    |-data-access-api
   |    |-data-access-impl
   |-+connector
   |    |-connector-api
   |    |-connector-implA
   |    |-connector-implB
   |-...

The presentation module is packaged in a war and it depends only on the api modules.

When i run the install goal the only dependencies that the war installs are the api modules. To choose wich impl modules to install in the presentation module i'm using profiles that add the dependency to the impl modules at build time depending on the profiles selected.

From what i've been reading i don't think that this is correct usage for the maven profiles.

What is the best way to tell maven to add a chosen impl to the presentation module?

Was it helpful?

Solution 2

I got a solution from the maven users mailing list that i think is the right way to use maven in my scenario.

I use runtime dependencies for the impl modules and one war project for each implementation of the api. Using war overlays it merges the resources and enables me to have the application running with the correct module implementations depending on the war i run.

OTHER TIPS

I have the same usage of profiles but only for specific changes (dependencies mostly).

You do not have to put everything in profiles. Most of the implementation dependencies are common and are therefore declare directly without profiles.

Depending on the targeted application server I use profiles to override properties, add specific dependencies (CommonJ for Websphere for instance), ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top