Search code examples
mavenmaven-pluginmulti-module

requiresDependencyResolution in a multi-module project


If you want to run a Maven goal that has requiresDependencyResolution = ResolutionScope.COMPILE in its @Mojo annotation, i.e. requires that all dependencies are resolved before it runs, you face a problem in a multi-module project.

If one module references another, this other module does not exist (when you start the goal with plugin:some-goal on the parent or child), and the resolution fails.

How should I use such a Maven plugin in the context of a multi-module project?


Solution

  • The trick is to use requiresDependencyCollection wherever possible because it does not require the other module to be built.