1.句法
mvn [options] [<goal(s)>] [<phase(s)>]
2.插件以及目标(goal)
plugin:goal
Plugin | Description |
---|---|
Core plugins | Plugins corresponding to default core phases (ie. clean, compile). They may have multiple goals as well. |
clean | Clean up after the build. |
compiler | Compiles Java sources. |
deploy | Deploy the built artifact to the remote repository. |
failsafe | Run the JUnit integration tests in an isolated classloader. |
install | Install the built artifact into the local repository. |
resources | Copy the resources to the output directory for including in the JAR. |
site | Generate a site for the current project. |
surefire | Run the JUnit unit tests in an isolated classloader. |
verifier | Useful for integration tests – verifies the existence of certain conditions. |
Packaging types/tools | These plugins relate to packaging respective artifact types. |
ear | Generate an EAR from the current project. |
ejb | Build an EJB (and optional client) from the current project. |
jar | Build a JAR from the current project. |
rar | Build a RAR from the current project. |
war | Build a WAR from the current project. |
app-client/acr | Build a JavaEE application client from the current project. |
shade | Build an Uber-JAR from the current project, including dependencies. |
source | Build a source-JAR from the current project. |
jlink | Build Java Run Time Image. |
jmod | Build Java JMod files. |
Reporting plugins | Plugins which generate reports, are configured as reports in the POM and run under the site generation lifecycle. |
changelog | Generate a list of recent changes from your SCM. |
changes | Generate a report from an issue tracker or a change document. |
checkstyle | Generate a Checkstyle report. |
doap | Generate a Description of a Project (DOAP) file from a POM. |
docck | Documentation checker plugin. |
javadoc | Generate Javadoc for the project. |
jdeps | Run JDK’s JDeps tool on the project. |
jxr | Generate a source cross reference. |
linkcheck | Generate a Linkcheck report of your project’s documentation. |
pmd | Generate a PMD report. |
project-info-reports | Generate standard project reports. |
surefire-report | Generate a report based on the results of unit tests. |
Tools | These are miscellaneous tools available through Maven by default. |
antrun | Run a set of ant tasks from a phase of the build. |
artifact | Manage artifacts tasks like buildinfo. |
archetype | Generate a skeleton project structure from an archetype. |
assembly | Build an assembly (distribution) of sources and/or binaries. |
dependency | Dependency manipulation (copy, unpack) and analysis. |
enforcer | Environmental constraint checking (Maven Version, JDK etc), User Custom Rule Execution. |
gpg | Create signatures for the artifacts and poms. |
help | Get information about the working environment for the project. |
invoker | Run a set of Maven projects and verify the output. |
jarsigner | Signs or verifies project artifacts. |
jdeprscan | Run JDK’s JDeprScan tool on the project. |
patch | Use the gnu patch tool to apply patch files to source code. |
pdf | Generate a PDF version of your project’s documentation. |
plugin | Create a Maven plugin descriptor for any mojos found in the source tree, to include in the JAR. |
release | Release the current project – updating the POM and tagging in the SCM. |
remote-resources | Copy remote resources to the output directory for inclusion in the artifact. |
scm | Execute SCM commands for the current project. |
scm-publish | Publish your Maven website to a scm location. |
scripting | The Maven Scripting Plugin wraps the Scripting API according to JSR223. |
stage | Assists with release staging and promotion. |
toolchains | Allows to share configuration across plugins. |
wrapper | Download and unpack the maven wrapper distribution (works only with Maven 4) |
Retired
Plugin | Type* | Version | Retired Date | Description |
---|---|---|---|---|
ant | B | 2.4 | 2019-06-02 | Generate an Ant build file for the project. |
eclipse | B | 2.10 | 2015-10-07 | Generate an Eclipse project files for the current project. |
idea | B | 2.2.1 | 2013-07-26 | Create/update an IDEA workspace for the current project (individual modules are created as IDEA modules) |
one | B | 1.3 | 2013-07-30 | A plugin for interacting with legacy Maven 1.x repositories and builds. |
reactor | B | 1.1 | 2014-03-24 | Build a subset of interdependent projects in a reactor (Maven 2 only). |
repository | B | 2.4 | 2019-04-30 | Plugin to help with repository-based tasks. |
At MojoHaus
Plugin | Description |
---|---|
animal-sniffer | Build signatures of APIs (JDK for example) and checks your classes against them. |
build-helper | Attach extra artifacts and source folders to build. |
castor | Generate sources from an XSD using Castor. |
clirr | Compare binaries or sources for compatibility using Clirr |
javacc | Generate sources from a JavaCC grammar. |
jdepend | Generate a report on code metrics using JDepend. |
nar-maven-plugin | Compiles C, C++, Fortran for different architectures. |
native | Compiles C and C++ code with native compilers. |
sql | Executes SQL scripts from files or inline. |
taglist | Generate a list of tasks based on tags in your code. |
versions | Manage versions of your project, its modules, dependencies and plugins. |
Misc
Plugin | Description |
---|---|
cargo | Start/stop/configure J2EE containers and deploy to them. |
clover | Generate a Clover report. |
jetty | Jetty Run a Jetty container for rapid webapp development. |
jalopy | Use Jalopy to format your source code. |
rat | Release Audit Tool (RAT) to verify files. |
Genesis Plugins | Verify legal files in artifacts. |
Apache Tomcat | Run an Apache Tomcat container for rapid webapp development. |
OWASP dependency-check | Run OWASP Dependency-Check, a utility that identifies project dependencies and checks if there are any known, publicly disclosed, vulnerabilities. |
CycloneDX | Generate Software Bill of Materials (SBOM) in CycloneDX format. |
pgpverify | Verify PGP signature of all project dependencies. |
buildplan | Inspect the lifecycle of your build. |
3.生命周期以及阶段(phase)
Clean Lifecycle
Phase | Description |
---|---|
pre-clean | execute processes needed prior to the actual project cleaning |
clean | remove all files generated by the previous build |
post-clean | execute processes needed to finalize the project cleaning |
Default Lifecycle
Phase | Description |
---|---|
validate | validate the project is correct and all necessary information is available. |
initialize | initialize build state, e.g. set properties or create directories. |
generate-sources | generate any source code for inclusion in compilation. |
process-sources | process the source code, for example to filter any values. |
generate-resources | generate resources for inclusion in the package. |
process-resources | copy and process the resources into the destination directory, ready for packaging. |
compile | compile the source code of the project. |
process-classes | post-process the generated files from compilation, for example to do bytecode enhancement on Java classes. |
generate-test-sources | generate any test source code for inclusion in compilation. |
process-test-sources | process the test source code, for example to filter any values. |
generate-test-resources | create resources for testing. |
process-test-resources | copy and process the resources into the test destination directory. |
test-compile | compile the test source code into the test destination directory |
process-test-classes | post-process the generated files from test compilation, for example to do bytecode enhancement on Java classes. |
test | run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed. |
prepare-package | perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package. |
package | take the compiled code and package it in its distributable format, such as a JAR. |
pre-integration-test | perform actions required before integration tests are executed. This may involve things such as setting up the required environment. |
integration-test | process and deploy the package if necessary into an environment where integration tests can be run. |
post-integration-test | perform actions required after integration tests have been executed. This may including cleaning up the environment. |
verify | run any checks to verify the package is valid and meets quality criteria. |
install | install the package into the local repository, for use as a dependency in other projects locally. |
deploy | done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. |
Site Lifecycle
Phase | Description |
---|---|
pre-site | execute processes needed prior to the actual project site generation |
site | generate the project’s site documentation |
post-site | execute processes needed to finalize the site generation, and to prepare for site deployment |
site-deploy | deploy the generated site documentation to the specified web server |
4.生命周期绑定
Maven 生命周期是抽象的,其本身不能做任何实际工作,这些实际工作(如源代码编译)都通过调用 Maven 插件 中的插件目标(plugin goal)完成的。
Clean Lifecycle Bindings
Phase | plugin:goal |
---|---|
clean | clean:clean |
Default Lifecycle Bindings – Packaging ejb
/ ejb3
/ jar
/ par
/ rar
/ war
Phase | plugin:goal |
---|---|
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war |
install | install:install |
deploy | deploy:deploy |
Default Lifecycle Bindings – Packaging ear
Phase | plugin:goal |
---|---|
generate-resources | ear:generate-application-xml |
process-resources | resources:resources |
package | ear:ear |
install | install:install |
deploy | deploy:deploy |
Default Lifecycle Bindings – Packaging maven-plugin
Phase | plugin:goal |
---|---|
generate-resources | plugin:descriptor |
process-resources | resources:resources |
compile | compiler:compile |
process-test-resources | resources:testResources |
test-compile | compiler:testCompile |
test | surefire:test |
package | jar:jar and plugin:addPluginArtifactMetadata |
install | install:install |
deploy | deploy:deploy |
Default Lifecycle Bindings – Packaging pom
Phase | plugin:goal |
---|---|
package | |
install | install:install |
deploy | deploy:deploy |
Site Lifecycle Bindings
Phase | plugin:goal |
---|---|
site | site:site |
site-deploy | site:deploy |
原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/experience/javae/6905.html