Índice
fundo
Existem muitos plug-ins usados no trabalho Maven
. Embora você possa copiar as configurações de outras pessoas da Internet, mas se quiser saber mais sobre os parâmetros de configuração disponíveis de um plug-in, não há como começar.
Obviamente, você pode visualizar o manual de ajuda no site oficial do plug-in ou pode visualizar a ajuda do plug-in por meio do Maven
comando help
, incluindo uma descrição breve e detalhada do plug-in, e também pode visualizar todos os objetivos do plug-in goal
, bem como os parâmetros de configuração do plug-in, etc.
comando de ajuda
Na linha de comando, use Maven
o help:describe
alvo para visualizar as informações do plug-in:mvn help:describe -Dplugin=插件标识
- Especifique o plug-in a ser visualizado por meio do parâmetro plug-in e o ID do plug-in pode estar na forma de groupId:artifactId[:version],
- Onde a versão é opcional,
- Também pode ser um prefixo de plug-in,
- É a abreviação de plug-in,
- Existe uma correspondência um-para-um entre os prefixos de plug-in e os plug-ins.
- Esta correspondência é armazenada nos metadados do repositório Maven:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
- Por exemplo, o prefixo do plugin help corresponde ao plugin maven-help-plugin
<plugin>
<name>Apache Maven Help Plugin</name>
<prefix>help</prefix>
<artifactId>maven-help-plugin</artifactId>
</plugin>
Exemplo de uso
Em seguida, verifique maven-help-plugin
as informações do plug-in, ou seja, verifique as informações do próprio comando de ajuda. Os dois comandos a seguir são equivalentes:
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin
mvn help:describe -Dplugin=help
Os resultados da consulta de saída são os seguintes
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-help-plugin:3.2.0
Name: Apache Maven Help Plugin
Description: The Maven Help plugin provides goals aimed at helping to make
sense out of the build environment. It includes the ability to view the
effective POM and settings files, after inheritance and active profiles have
been applied, as well as a describe a particular plugin goal to give usage
information.
Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help
This plugin has 8 goals:
help:active-profiles
Description: Displays a list of the profiles which are currently active for
this build.
help:all-profiles
Description: Displays a list of available profiles under the current
project.
Note: it will list all profiles for a project. If a profile comes up with a
status inactive then there might be a need to set profile activation
switches/property.
help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
help:effective-pom
Description: Displays the effective POM as an XML for this build, with the
active profiles factored in, or a specified artifact. If verbose, a comment
is added to each XML element describing the origin of the line.
help:effective-settings
Description: Displays the calculated settings as XML for this project,
given any profile enhancement and the inheritance of the global settings
into the user-level settings.
help:evaluate
Description: Evaluates Maven expressions given by the user in an
interactive mode.
help:help
Description: Display help information on maven-help-plugin.
Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
help:system
Description: Displays a list of the platform details like system properties
and environment variables.
For more information, run 'mvn help:describe [...] -Ddetail'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.613 s
[INFO] Finished at: 2021-10-12T15:38:22+08:00
[INFO] ------------------------------------------------------------------------
Você pode ver que maven-help-plugin
o prefixo do plug-in correspondente éhelp
Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help
Você pode ver help:describe
as propriedades e destinos usados para visualizar o plug-in
help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
- Você pode ver a ajuda que vem com o comando help:
mvn help:help
- O resultado da saída é basicamente o mesmo que acima
- Recomenda-se usar o comando help:describe aqui
verifique as informações detalhadas
Ao anexar -Ddetail
parâmetros ao comando, você pode visualizar os detalhes do plug-in:
简略信息:
mvn help:describe -Dplugin=help
详细信息:
mvn help:describe -Dplugin=help -Ddetail
As informações detalhadas são geradas da seguinte forma, que é goal
a descrição de cada parâmetro de configuração que pode ser visto
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-help-plugin:3.2.0
Name: Apache Maven Help Plugin
Description: The Maven Help plugin provides goals aimed at helping to make
sense out of the build environment. It includes the ability to view the
effective POM and settings files, after inheritance and active profiles have
been applied, as well as a describe a particular plugin goal to give usage
information.
Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help
This plugin has 8 goals:
help:active-profiles
Description: Displays a list of the profiles which are currently active for
this build.
Implementation: org.apache.maven.plugins.help.ActiveProfilesMojo
Language: java
Available parameters:
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
help:all-profiles
Description: Displays a list of available profiles under the current
project.
Note: it will list all profiles for a project. If a profile comes up with a
status inactive then there might be a need to set profile activation
switches/property.
Implementation: org.apache.maven.plugins.help.AllProfilesMojo
Language: java
Available parameters:
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
Implementation: org.apache.maven.plugins.help.DescribeMojo
Language: java
Available parameters:
artifactId
User property: artifactId
The Maven Plugin artifactId to describe.
Note: Should be used with groupId parameter.
cmd
User property: cmd
A Maven command like a single goal or a single phase following the Maven
command line:
mvn [options] [<goal(s)>] [<phase(s)>]
detail (Default: false)
User property: detail
This flag specifies that a detailed (verbose) list of goal (Mojo)
information should be given.
goal
User property: goal
The goal name of a Mojo to describe within the specified Maven Plugin. If
this parameter is specified, only the corresponding goal (Mojo) will be
described, rather than the whole Plugin.
groupId
User property: groupId
The Maven Plugin groupId to describe.
Note: Should be used with artifactId parameter.
minimal (Default: false)
User property: minimal
This flag specifies that a minimal list of goal (Mojo) information should
be given.
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
plugin
Alias: prefix
User property: plugin
The Maven Plugin to describe. This must be specified in one of three
ways:
1. plugin-prefix, i.e. 'help'
2. groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
3. groupId:artifactId:version, i.e.
'org.apache.maven.plugins:maven-help-plugin:2.0'
version
User property: version
The Maven Plugin version to describe.
Note: Should be used with groupId/artifactId parameters.
help:effective-pom
Description: Displays the effective POM as an XML for this build, with the
active profiles factored in, or a specified artifact. If verbose, a comment
is added to each XML element describing the origin of the line.
Implementation: org.apache.maven.plugins.help.EffectivePomMojo
Language: java
Available parameters:
artifact
User property: artifact
The artifact for which to display the effective POM.
Note: Should respect the Maven format, i.e. groupId:artifactId[:version].
The latest version of the artifact will be used when no version is
specified.
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
verbose (Default: false)
User property: verbose
Output POM input location as comments.
help:effective-settings
Description: Displays the calculated settings as XML for this project,
given any profile enhancement and the inheritance of the global settings
into the user-level settings.
Implementation: org.apache.maven.plugins.help.EffectiveSettingsMojo
Language: java
Available parameters:
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
showPasswords (Default: false)
User property: showPasswords
For security reasons, all passwords are hidden by default. Set this to
true to show all passwords.
help:evaluate
Description: Evaluates Maven expressions given by the user in an
interactive mode.
Implementation: org.apache.maven.plugins.help.EvaluateMojo
Language: java
Available parameters:
artifact
User property: artifact
An artifact for evaluating Maven expressions.
Note: Should respect the Maven format, i.e. groupId:artifactId[:version].
The latest version of the artifact will be used when no version is
specified.
expression
User property: expression
An expression to evaluate instead of prompting. Note that this must not
include the surrounding ${...}.
forceStdout (Default: false)
User property: forceStdout
This options gives the option to output information in cases where the
output has been suppressed by using -q (quiet option) in Maven. This is
useful if you like to use maven-help-plugin:evaluate in a script call
(for example in bash) like this:
RESULT=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo $RESULT
This will only printout the information which has been requested by
expression to stdout.
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console. This parameter will be ignored if no
expression is specified.
Note: Could be a relative path.
help:help
Description: Display help information on maven-help-plugin.
Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
Implementation: org.apache.maven.plugins.help.HelpMojo
Language: java
Available parameters:
detail (Default: false)
User property: detail
If true, display all settable properties for each goal.
goal
User property: goal
The name of the goal for which to show help. If unspecified, all goals
will be displayed.
indentSize (Default: 2)
User property: indentSize
The number of spaces per indentation level, should be positive.
lineLength (Default: 80)
User property: lineLength
The maximum length of a display line, should be positive.
help:system
Description: Displays a list of the platform details like system properties
and environment variables.
Implementation: org.apache.maven.plugins.help.SystemMojo
Language: java
Available parameters:
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.904 s
[INFO] Finished at: 2021-10-12T15:53:53+08:00
[INFO] ------------------------------------------------------------------------
ver alvo específico
Você pode -Dgoal
visualizar as informações detalhadas do alvo especificado por meio dos parâmetros:
简略信息:
mvn help:describe -Dplugin=help -Dgoal=describe
详细信息:
mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail
A breve saída de informações é a seguinte
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] Mojo: 'help:describe'
help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
For more information, run 'mvn help:describe [...] -Ddetail'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.031 s
[INFO] Finished at: 2021-10-12T15:56:50+08:00
[INFO] ------------------------------------------------------------------------
A saída de informações detalhadas é a seguinte
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] Mojo: 'help:describe'
help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
Implementation: org.apache.maven.plugins.help.DescribeMojo
Language: java
Available parameters:
artifactId
User property: artifactId
The Maven Plugin artifactId to describe.
Note: Should be used with groupId parameter.
cmd
User property: cmd
A Maven command like a single goal or a single phase following the Maven
command line:
mvn [options] [<goal(s)>] [<phase(s)>]
detail (Default: false)
User property: detail
This flag specifies that a detailed (verbose) list of goal (Mojo)
information should be given.
goal
User property: goal
The goal name of a Mojo to describe within the specified Maven Plugin. If
this parameter is specified, only the corresponding goal (Mojo) will be
described, rather than the whole Plugin.
groupId
User property: groupId
The Maven Plugin groupId to describe.
Note: Should be used with artifactId parameter.
minimal (Default: false)
User property: minimal
This flag specifies that a minimal list of goal (Mojo) information should
be given.
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
plugin
Alias: prefix
User property: plugin
The Maven Plugin to describe. This must be specified in one of three
ways:
1. plugin-prefix, i.e. 'help'
2. groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
3. groupId:artifactId:version, i.e.
'org.apache.maven.plugins:maven-help-plugin:2.0'
version
User property: version
The Maven Plugin version to describe.
Note: Should be used with groupId/artifactId parameters.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.162 s
[INFO] Finished at: 2021-10-12T15:57:13+08:00
[INFO] ------------------------------------------------------------------------
outros comandos
Existem muitos plugins auxiliares úteis goal
, apenas alguns dos mais usados estão listados abaixo, tente mais por conta própria.
- Visualize os
pom.xml
resultados efetivos específicos atuais e a saída para o arquivo:mvn help:effective-pom -Doutput=EffectivePom.xml
pom
Ativo durante a visualizaçãoprofile
:mvn help:active-profiles -N
- Veja todas as variáveis de ambiente do sistema:
mvn help:system