您可以通過調用檢索有關MavenProject
的路徑元素:
樣本MOJO是:
@Mojo(name = "foo", requiresDependencyResolution = ResolutionScope.TEST)
public class MyMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
getLog().info(project.getCompileClasspathElements().toString());
getLog().info(project.getRuntimeClasspathElements().toString());
getLog().info(project.getTestClasspathElements().toString());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error while determining the classpath elements", e);
}
}
}
是什麼讓這個工作:
- 的
MavenProject
被注射使用${project}
財產
requiresDependencyResolution
將啓用該插件訪問的@Parameter
註釋項目與提及的決議範圍的依賴關係。
requiresDependencyResolution無效。項目具有zip依賴性。 –