Rid*_*del 4 classpath maven-plugin maven
我正在写一个maven 3插件,我想使用项目类路径.
我已经尝试使用添加maven-build-classpath中提到的方法来插件执行类路径,但似乎maven找不到写入的组件.(我有一个ComponentNotFoundException插件执行开始).
那么,在maven 3插件中使用项目类路径的"参考"方式是什么?或者,如果组件方式是正确的,那么除了将组件添加为注释的configurator属性之外,是否还有任何配置步骤@Mojo?
您可以MavenProject通过调用来检索类路径元素:
getCompileClasspathElements() 检索由编译范围的依赖项形成的类路径getRuntimeClasspathElements() 检索由运行时范围的依赖项(即编译+运行时)形成的类路径getTestClasspathElements() 检索由测试范围依赖项形成的类路径(即编译+系统+提供+运行时+测试)一个示例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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
是什么让这项工作:
MavenProject与注射@Parameter使用注释${project}属性requiresDependencyResolution 将使插件能够使用上述分辨率范围访问项目的依赖项.| 归档时间: |
|
| 查看次数: |
2042 次 |
| 最近记录: |