当我运行干净的Maven配置文件构建(“mvn clean install -PmyProfile”)时,如果构建失败,我希望能够向用户显示自定义的静态文本消息。
例如,从中:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:54.666s
[INFO] Finished at: Mon May 13 10:44:48 MDT 2013
[INFO] Final Memory: 27M/81M
[INFO] ------------------------------------------------------------------------
到此:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:54.666s
[INFO] Finished at: Mon May 13 10:44:48 MDT 2013
[INFO] Final Memory: 27M/81M
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] For troubleshooting steps for your build, go to http://www.somewhere.com
[INFO]
[INFO] If you continue to have trouble, email Some Guy at some_guy@somewhere.com
[INFO]
Maven可以吗?
答案 0 :(得分:0)
使用处理MojoFailureException的组件:
@Component
private MojoExecution execution;
public void execute() throws MojoExecutionException, MojoFailureException
{
for (Artifact artifact : (Collection<Artifact>) execution.getMojoDescriptor().getPluginDescriptor().getArtifacts())
{
getLog().info("Artifact: " + artifact);
}
}
<强>参考强>