开发者

Maven make phase conditional

I want to make some 开发者_高级运维phases optional say if compile fails or test fails and complete other phases like checkstyle, findbugs. Can i do that in maven, i have done it in ant not sure how to go about in maven


Maven has no means to dynamically add or remove goals or lifecycle phases. Yes, you could probably achieve functionality like that by writing a plugin and using the <extension> mechanism, but you would be breaking standard conventions.

But all plugins you talk about have parameters you can set to not fail the build:

  • compiler:compile has the failOnError parameter
  • surefire:test has the testFailureIgnore parameter
  • findbugs:check has the failOnError parameter
  • checkstyle:check has the failsOnError parameter

My suggestion would be to have a profile where you add configurations with all of these parameters, so you can toggle all of them with a single command.


You will probably need to write your own small plugin for Maven in order to handle this. You may want to see this thread: http://www.mail-archive.com/users@maven.apache.org/msg95552.html


Maven encourage you to play with "goal-to-phase assignments", instead of explicit instructions about when to run what. Maven lifecycle is your roadmap, which you can't change. And on every milestone (phase) in this roadmap you can do certain operations (goals). In other words, you have to forget Ant and start using Maven :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜