在 Mojo 中,我需要扫描作为插件的所有模块依赖项,为此我使用 mavenProject.getArtifacts()。如果我直接构建模块,这工作正常,所以不是从父级构建,而是在 de 模块的目录中调用“mvn clean package”。在这种情况下,我得到了该模块的所有依赖项。
但是,如果我构建整个项目,那么当构建到达模块时,我会得到一组完全不同的依赖项。我不明白为什么。该插件在模块的 pom 中定义。
mavenProject 在 Mojo 中通过以下方式获得:
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject mavenProject;
当然包括:
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME
如果我直接构建模块,我会得到:
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
如果模块是作为整个项目的一部分构建的,我会得到:
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
谁能解释为什么我对同一个模块有不同的依赖关系?