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

How can one find the default goal for a maven plugin without reading the source?

给定一个 maven 插件,是否有任何命令可以用来查看其 mojos 的默认 phase/goal 绑定?我意识到,如果我查看源代码或生成的 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.

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

除上述之外,您还可以像这样使用生命周期的绑定文档:

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:
  ...

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