Best “General Purpose” Maven plugins [closed]

本秂侑毒 提交于 2019-12-18 09:58:06

问题


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)


回答1:


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.




回答2:


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.



回答3:


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.




回答4:


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.



回答5:


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.




回答6:


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



回答7:


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.




回答8:


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.




回答9:


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.




回答10:


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.




回答11:


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




回答12:


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.



来源:https://stackoverflow.com/questions/2616397/best-general-purpose-maven-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!