Search code examples
maven

Does Maven support multiple variants?


I have a pom for multiple clients, the client specific code is in com.foo.custom. So, for customer A there are classes in com.foo.custom.customerA, for customer B some classes in com.foo.custom.customerB etc. The set of classes in com.foo.custom.customerA is different from those in com.foo.custom.customerB.

When I do mvn package, the code for all the customers shows up in the jar, as expected. Is there a way of selecting just one customer, e.g. mvn package -Dcust=customerB, and then have that one customer in the package and the others not?


Solution

  • You can construct a multi-module project with modules like

    • common
    • customerA
    • customerB
    • ...

    The customerX modules use common as dependency.