3

当我运行干净的 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 中可能吗?

4

1 回答 1

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);
    }
  }

参考

于 2013-12-09T19:51:12.737 回答