java - 如何在不阅读源代码的情况下找到 Maven 插件的默认目标?

标签 java maven maven-plugin

给定一个 Maven 插件,是否有任何命令可以用来查看其 mojos 的默认阶段/目标绑定(bind)?我意识到,如果我查看源代码或生成的 javadoc,我可以找到注释。然而这似乎太间接了。

我已经尝试了 :help 目标,但这也没有给我任何其他信息。

采取maven-javadoc-plugin例如。该插件有 14 个不同的可访问目标。然而,我不需要为要生成的 javadoc 显式分配阶段或目标。

是否有任何工具可以用来查看哪些目标默认分配给哪个阶段(对于任何插件 - 不仅仅是 javadoc 插件)?

最佳答案

如果你看一下documentation of the plugins你会发现类似这样的东西:

Attributes:

Requires a Maven project to be executed.
Requires dependency resolution of artifacts in scope: compile.
The goal is thread-safe and supports parallel builds.
Since version: 2.0.
Invokes the execution of the lifecycle phase generate-sources prior to executing itself.

最后一行将为您提供此信息。

或者像这样 maven-war-plugin docs:

Attributes:

Requires a Maven project to be executed.
Requires dependency resolution of artifacts in scope: runtime.
The goal is thread-safe and supports parallel builds.
Binds by default to the lifecycle phase: package.

最后一行显示默认生命周期阶段。

除了上述之外,您还可以使用生命周期的绑定(bind)文档,如下所示:

https://maven.apache.org/ref/3.0.5/maven-core/default-bindings.html https://maven.apache.org/ref/3.1.1/maven-core/default-bindings.html https://maven.apache.org/ref/3.2.5/maven-core/default-bindings.html https://maven.apache.org/ref/3.3.3/maven-core/default-bindings.html

您还可以通过以下方式在命令行上获取这些信息:

mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-jar-plugin  -Ddetail

您将得到如下输出(以及更多输出):

jar:jar
  Description: Build a JAR from the current project.
  Implementation: org.apache.maven.plugin.jar.JarMojo
  Language: java
  Bound to phase: package

  Available parameters:
  ...

在我看来,这就是您正在寻找的东西。

关于java - 如何在不阅读源代码的情况下找到 Maven 插件的默认目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30083901/

相关文章:

Java/Wicket 口 : Compile Basic Hello World with Resources

java - Libgdx:即使在成功构建后,库也不会显示在自动完成中?

eclipse - 在 Maven 项目中更新 .settings/org.eclipse.wst.common.component 文件

Maven 用于多个模块

java - 设置枚举值

java - 使用异常进行控制流

java - 将 native sql 转换为未映射的对象

java - 如何在文件夹级别读取 Jenkins 凭据

java - 如何从插件中读取 .m2/settings.xml 文件中的 Maven 设置

java - Maven 无法从 .m2/repository 找到 jar