java 最佳“通用”Maven 插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2616397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best "General Purpose" Maven plugins
提问by ripper234
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?
我们刚刚转向 Maven,我知道有很多不同的插件和扩展。您推荐哪些用于一般用途的最佳产品?
(On plugin per answer please)
(请在每个答案的插件上)
回答by Bozhidar Batsov
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.
当然,还有更多探索,很大程度上取决于您的项目需求。当然,我使用的最有用的插件之一是我自己为某些特定需求编写的插件。这是 maven 最有价值的特性之一——轻松扩展它的能力。
回答by Pascal Thivent
The Maven Versions Plugin, very useful to check and manage versions of POMs and dependencies:
在Maven的版本插件,检查和管理的POM和依赖的版本非常有用:
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.
versions:display-dependency-updates- 扫描项目的依赖项并生成具有可用更新版本的依赖项的报告。versions:display-plugin-updates- 扫描项目的插件并生成具有可用更新版本的插件的报告。versions:update-child-modules- 更新项目子模块的父部分,使版本与当前项目的版本匹配。例如,如果您有一个聚合器 pom,它也是它聚合的项目的父级,并且子级和父级版本不同步,则此 mojo 可以帮助修复子模块的版本。(请注意,如果您的项目因版本不匹配而无法构建,您可能需要使用 -N 选项调用 Maven 以运行此目标)。versions:set- 可用于从命令行设置项目版本。
回答by James Kingsbery
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:
maven jetty 插件非常棒,它有助于使 Web 应用程序开发更容易。您可以简单地执行以下操作,而不是打包您的应用程序:
mvn jetty:run
And your application starts.
然后您的应用程序启动。
回答by Pascal Thivent
The Maven Dependency Pluginis another mandatory plugin to debug/clean/understand a POM and how you get some dependency (transitively):
在Maven的依赖插件是另一种强制性的插件调试/清洁/了解POM以及如何得到一些依赖(及物动词):
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.
dependency:analyze- 分析此项目的依赖关系并确定哪些是:已使用和已声明;已使用和未申报;未使用并已声明。dependency:tree- 显示该项目的依赖树。
回答by Pascal Thivent
The Maven Enforcer Pluginwhich 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.
在Maven的强制实施插件,它允许控制所有的插件有一个指定的版本或特定环境的限制,如Maven的版本,JDK版本和操作系统的家庭多了很多标准规则和用户创建的规则一起。
回答by Pascal Thivent
The Maven Help Pluginwhich is mandatory to debug a POM:
调试 POM 所必需的Maven 帮助插件:
help:effective-pom– to displays the effective POMhelp:active-profiles- to lists the profiles which are currently active for the build.help:evaluate- to evaluate maven expressions
help:effective-pom– 显示有效的 POMhelp:active-profiles- 列出当前对构建有效的配置文件。help:evaluate- 评估 Maven 表达式
回答by CRH
The Maven FindBugs Pluginis something you want for static code analysis. It is very useful to detect bugs that are not covered by your developer tests.
在Maven的FindBugs的插件是你想要的东西的静态代码分析。检测开发人员测试未涵盖的错误非常有用。
回答by CRH
Maven Cargo Pluginto 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.
用于启动和停止 Web 容器的Maven Cargo 插件。您还可以使用它来将您的 Web 应用程序部署到正在运行的容器。我们将其用于 Web 应用程序的集成和功能测试。
回答by Anshul
The exec-maven-pluginis extremely useful for running tasks not covered by known plugins.
在EXEC-Maven的插件是运行不属于已知的插件的任务是非常有用的。
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.
它有两个目标,第一个 'exec' 允许您运行任何可执行文件,就像您在任何阶段从命令行运行它一样。第二个目标“java”允许您运行任何 java 类。
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.
当我不得不添加由 CUP 生成的 Parser 类时,这是一个救命稻草。没有 CUP maven 插件,但 exec 允许我执行 CUP 的主要 java 类来生成我的解析器。
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.
我可以想到任何数量的用途;然而很难找到;它的存在应该贴在 maven 文档的首页上。
回答by Sean Patrick Floyd
The GMaven pluginlets you embed groovy code in your lifecycle.
GMaven 插件可让您在生命周期中嵌入 groovy 代码。
It let's you execute Groovy codeeither from
它让你执行Groovy代码,无论从
It also Simplifies the Creation of Groovy-based Maven Plugins

