开发者

Best "General Purpose" Maven plugins [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this ques开发者_开发问答tion will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

We are just moving to Maven, and I understand there is a world of different plugins & extensions. Which are the best ones you recommend for general usage?

(On plugin per answer please)


I find these plugins the most useful in my day-to-day work:

  • surefire - for unit testing
  • dependency - for module dependency analysis
  • cobertura - for unit test coverage analysis
  • liquibase - for running database migrations
  • assembly - for creating single executable jars containing all the required dependencies of an app

There is so much more explore and much depends on your project needs of course. And of course one of the most useful plugins that I use are the ones I wrote myself for some specific needs. This is one of the most valuable features of maven - the ability to easily extend it.


The Maven Versions Plugin, very useful to check and manage versions of POMs and dependencies:

  • versions:display-dependency-updates - scans a project's dependencies and produces a report of those dependencies which have newer versions available.
  • versions:display-plugin-updates - scans a project's plugins and produces a report of those plugins which have newer versions available.
  • versions:update-child-modules - updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).
  • versions:set - can be used to set the project version from the command line.


The maven jetty plugin is pretty awesome, it helps make web application development much easier. Rather than packaging your application, you can simply do this:

mvn jetty:run

And your application starts.


The Maven Dependency Plugin is another mandatory plugin to debug/clean/understand a POM and how you get some dependency (transitively):

  • dependency:analyze - analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
  • dependency:tree - displays the dependency tree for this project.


The Maven Enforcer Plugin which allows to control that all plugins have a specified version or certain environmental constraints such as Maven version, JDK version and OS family along with many more standard rules and user created rules.


The Maven Help Plugin which is mandatory to debug a POM:

  • help:effective-pom – to displays the effective POM
  • help:active-profiles - to lists the profiles which are currently active for the build.
  • help:evaluate - to evaluate maven expressions


The Maven FindBugs Plugin is something you want for static code analysis. It is very useful to detect bugs that are not covered by your developer tests.


Maven Cargo Plugin to start and stop your Web Container. You can also use it to deploy your web app to a running container. We use it for integration and functional test for our web applications.


The exec-maven-plugin is extremely useful for running tasks not covered by known plugins.

It has two goals, the first one 'exec' allows you to run any executable as if you were running it from the command line at any stage. The second goal 'java' allows you to run any java class.

It was a life-saver when I had to add in a Parser class generated by CUP. There's no CUP maven plugin, but exec allowed me to execute CUP's main java class for generating my parser.

I can think of any number of uses for this; and yet it was quite hard to find; its existence should be plastered across the front page of the maven documentation.


Excuse the book plugin, but this is just easier than repeating each plugin :)

  • https://www.packtpub.com/article/useful-maven-plugins-part1
  • https://www.packtpub.com/article/useful-maven-plugins-part2

Some have been covered here, but this includes several more.


The GMaven plugin lets you embed groovy code in your lifecycle.

It let's you execute Groovy code either from

  1. an inline code snippet in your pom or
  2. source files in your project or
  3. remote source files.

It also Simplifies the Creation of Groovy-based Maven Plugins


Typically, one plugin has a specific purpose, i.e. the plugins that you will use depend on the things that you would like todo. For example, if you would like to specify the source version, use maven-compiler-plugin, or maven-javadoc-plugin for generating javadocs. Other plugins may start a jetty prior to running your integration tests, and there are plugins that deploy your binary release to your application server, etc.

For a general overview, please visit the Maven - Available Plugins or the the plugins directory at the Maven Central Repository. There are also many plugins at Mojo project at Codehaus. The corresponding repository can be found here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜