Managing different dependency contexts in java (maven) project

39 Views Asked by At

I have an applicatoin where all the code is very cohesive, but runs in different class environments. The application does the same thing many ways, using different APIs.

I want to thus have different parts of the build run with different classpaths. What are the pros/cons of using

  • maven submodules

versus

  • maven profiles

To accomplish this ?

In the build, i need to integrate the results of all code paths into a final test - so I cannot separate this project into completely separate source code-bases .

1

There are 1 best solutions below

0
On

As far as I understand your application have some common code and few different apis. One way to separate independent part of code like apis, would be to create a common project (submodule) and a few api projects (other submodules), that are dependent only from the common project.

If you need to integrate all apis for the final test, you could create another project, that would be dependent from all other projects (including apis) and when this project is build, there is created a single artifact that is enterprise archive (EAR) that contains dependent projects inside of it. This can be achieved with maven ear plugin http://maven.apache.org/plugins/maven-ear-plugin.