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)
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)
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.
I find these plugins the most useful in my day-to-day work:
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 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 expressionsThe 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 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.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 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.
Excuse the book plugin, but this is just easier than repeating each plugin :)
Some have been covered here, but this includes several more.
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 GMaven plugin lets you embed groovy code in your lifecycle.
It let's you execute Groovy code either from
It also Simplifies the Creation of Groovy-based Maven Plugins
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.