Hi everyone,
I’d like to propose a new contrib maven plugin, which aims to reduce a bit the struggle we have when creating extensions which depends on other extensions with a different parent version.
When creating an extension which depends on other extensions, we often run into errors during the build because of the Maven Enforcer plugin. Currently, we have a lot of enforcer rules defined in Commons and Platform (an example here) which can easily break the build when an extension has dependencies to other extensions with a different contrib-parent version.
To resolve these issues, there are currently two possible options :
- Either skip the enforcer goals with
xwiki.enforcer.skip
; which is quick to do, but some breakages could be not related to the use of XS dependencies. - Or declare all the APIs that the project depends on transitively as managed dependencies in the project parent POM. We have this in Change Request, for example. The issue here is that the project may depend on a lot of XS deps, and it’s tedious to go through the whole list.
The goal for this plugin is to actually do the heavy-lifting work of collecting XS dependencies and adding them as managed dependencies in the project, before running the enforcer goals. It works as follows :
- The plugin configuration gets a list of “managed dependency sources” (there’s probably a better name), which are actually artifacts coordinates. The two default sources will be :
org.xwiki.platform:xwiki-platform-distribution-war-dependencies/${platform.version}
org.xwiki.platform:xwiki-platform-distribution-flavor-common/${platform.version}
- The plugin resolves the dependencies of these artifacts, and filters out any artifact that don’t have a group ID within a pre-defined list. The default list of group IDs to keep will be :
org.xwiki.platform
org.xwiki.rendering
org.xwiki.commons
- Each artifact that has not been filtered out gets added in the project managed dependencies.
I already have a working prototype that I tested successfully on Change Request and the XWiki Pro Package. LMK if you identify issues that could come from this strategy.
The main issue I identified so far is that you will need to call this plugin before calling dependency:tree
if you want to see the actual tree of dependencies as it will be used during the build. Otherwise, I observe that the output of the dependency tree is the same as if I had added manually the platform dependencies by hand.
I plan to call this plugin managed-dependencies-maven-plugin
(to stick with Maven plugin naming conventions). If you have a better idea for a name, don’t hesitate.
Thanks,
Clément