In a Mojo I need to scan all of the module's dependencies where it is a plugin, for that I use mavenProject.getArtifacts(). This works fine if I build the module directly, so not from the parent, but just call "mvn clean package" in de module's directory. In that case I get all the dependencies of that module.
However if I build the whole project, then when the build reaches the module I get a totally different set of dependencies. I do not understand why. The plugin is defined in the pom of the module.
The mavenProject is obtained in the Mojo by:
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject mavenProject;
Ofcourse including:
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME
If I build the module directly I get this:
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/planon-fm/planonee/PlanonUX/201501.0.33.0/PlanonUX-201501.0.33.0.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/planon/tms/scheduler/SchedulerService/1.1.2/SchedulerService-1.1.2.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/org/mockito/mockito-core/2.12.0/mockito-core-2.12.0.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/google/guava/guava/23.6-jre/guava-23.6-jre.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/nl/planon/querybuilder/querybuilder-api-impl/3.0.4/querybuilder-api-impl-3.0.4.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/planon/tms/lib/sx/sx-utils201210/2.1.0/sx-utils201210-2.1.0.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/nl/planon/querybuilder/querybuilder-api/1.2.0/querybuilder-api-1.2.0.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/planonsoftware/hades/17.0.4.9-1/hades-17.0.4.9-1.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/junit/junit/4.12/junit-4.12.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/com/planon/tms/myclient/myclient-shared/1/myclient-shared-1.jar!/model.xml
If the module is build as part of the whole project I get:
Examining jar:file:/C:/Users/tbeuge/.m2/repository/org/mockito/mockito-core/2.12.0/mockito-core-2.12.0.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/junit/junit/4.12/junit-4.12.jar!/model.xml
Examining jar:file:/C:/Users/tbeuge/.m2/repository/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar!/model.xml
Can anybody explain why I get different dependencies for the same module?