In my application built by Maven I have two platform-specific dependencies that are mutually exclusive. During the project's build I would like to build two runnable jars where one jar contains one dependency and the second jar contains the other dependency.
My first thought was to create two build profiles where each one contains one of the dependencies and the Maven Assembly or Shade plugin to build a runnable jar. Unfortunately that does not seem to work because only one of the jars will build. I tried enabling both on the command line (-Pprofile1,profile2
), setting both activeByDefault
to true
but still no luck.
Before I try to work around it by creating two project submodules to do the builds, is there a way to build two runnable jars with different dependencies in the same Maven project?
For those interested, using two separate modules was the best solution for me. There is one project ("main") that contains all the code. There are two other projects where each project declares the dependency it requires for its specific platform and the project "main." Each project then builds a runnable jar for its platform.