I have a project consisting of 3 libraries – let’s call them 1) BABY, 2) CHILD and 3) ADULT. Lib “CHILD” depends on “BABY” and “ADULT” depends on “CHILD”.
What I want to do is produce:
- a dev version that has all the (transitive) dependencies
- a production version that creates a standalone JAR for each library (embedding the dependencies)
I have a profile dev and a profile release already, and I know how to use ProGuard to generate the JAR.
The question is how to tell Maven to keep all dependencies in dev and ignore them (optional/provided) in production?
Here is what I used eventually:
The parent POM defines a profile
releasethat configurates theproguard plugin(crates one big JAR) and theinstall plugin(places the release artifact in the repo).The lib-baby POM simply calls the 2 plugins in the
<build>section.The lib-child POM additionally specifies a
devprofile where the dependency tolib-babyis defined. Within the release profile this dependency has anoptionaltag and is included in the big JAR.In the end when run by default, the libs
com.company.dev:lib-babyandcom.company.dev:lib-childare created (included their dependencies).When run with
-Preleasethe libscom.company:lib-babyandcom.company:lib-childare created (standalone libs [WITHOUT any dependencies]) – only side effect is that the default artifacts (.*dev) are overwritten 🙁parent:
lib-baby:
lib-child: