My current setup consists of:
- a parentPom in a plugin
- a customPlugin version 2.0 compatible with maven2 only
- a customPlugin version 3.0 compatible with maven3 only
various projects referencing the parentPom and using my customPlugin. When users use maven2, the customPlugin should be version2 – when they use maven3, it should be version3 of the customPlugin.
I originally followed this guide
As describe in the above page, the detection of the maven version can be done using a profile and the {basedir} property. The detection mechanism is implemented in the parentPom. The problem I am running into is that my projects do not activate the maven3 detection mechanism in the profile. I believe this is due to the fact that profiles are not inherited in maven.
What would you recommend to do in order to:
– avoid declaring explicitly the pluginVersion in the child poms
– provide maven2 and maven3 compatibility
Thank you so much for your help.
Use your plugin version declaration within
<build><pluginManagement> ...inside profiles (activated by Maven version) at your parent POM level. Then, you can use the plugin anywhere (at parent POM or modules) without specifying version and it should work as you need it.