MAVEN is essentially a framework for executing plug-ins. Plug-ins are divided into two categories: Build plug-ins and reporting plugins.
- The build plugin , which is executed during the build phase, should be configured in the <build/> element of the Pom.
- Reporting plug-ins , which are executed when the site is generated, should be configured in the <reporting/> element of the Pom. Because the result of the reporting plugin is part of the generated site, this plug-in should be internationalized and localized. See http://maven.apache.org/plugins/localization.html here for more details.
But all plugins need to specify at least: GroupId, Artifactid, and version.
General configuration
The MAVEN plugin is configured by specifying a <configuration> element. The child elements in the element are the property in the Mojo.
See http://maven.apache.org/guides/mini/guide-configuring-plugins.html.
Configuring the Build Plugin
The following is simply configuring the build plugin in the <build> element.
Use <executions> tags
<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<< to be continued here >>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>
Add-ons supported by MAVEN projects
There is a list of the latest plugins in org/apache/maven/plugins .
Core Plugins
Clean is responsible for the cleanup after build
compiler compiling Java source code
Deploy deploys the built-in artifact to the remote repository
failsafe running the JUnit integration test in an isolated class loader
Install Deploy the built-in artifact to the local warehouse
Resources copies the resource to the output folder to include in the jar.
site builds a web for the current project
Surefire running JUnit unit tests in an isolated class loader
verifier Useful for integration testing-verifying the existence of specific environments
The Type/tool responsible for packaging
ear generates an ear for the current project
jar to build a jar from the current project
rar constructs a RAR from the current project
War builds a war from the current project
Shade builds a uber_jar from the current project, containing dependencies. (also called fat jar or Super jar)
source builds a source jar from the current project
Add-ons outside of maven: codehaus.org, code.google.com, misc
Misc, other abbreviations. Mainly refers to the Maven plugin provided by each project, which only lists two:
Jetty
Apache Tomcat
Here are some examples to illustrate how to use
One, the war plugin, there are 4 ways to use it:
- Package a project into a war type
- Call War:war Goal
- Call war:exploded Goal
- Call War:inplace Goal
Note: When War:goals is used, it assumes that the compile phase is complete.
<Project> ... <Build> <!--defining versions in the parent Pom - <pluginmanagement> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-war-plugin</Artifactid> <version>3.0.0</version> </plugin> ... </Plugins> </pluginmanagement> <!--using a plug-in in a pom or parent pom - <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-war-plugin</Artifactid> <version>3.0.0</version> </plugin> ... </Plugins> </Build> ...</Project>
<Project> ... <groupId>Com.example.projects</groupId> <Artifactid>Documentedproject</Artifactid> <Packaging>War</Packaging> <version>1.0-snapshot</version> <name>Documented Project</name> <URL>http://example.com</URL> ...</Project>
- Calling the mvn package or mvn compile War:war, the corresponding version of the war file is produced under target/ (the file name is: Artifactid-version.war).
- Calling mvn compile war:exploded generates a non-packaged War folder under target/ . The name of the folder is finalname, and Finalname is usually the artifactid-version form. Of course, you can override the default by setting the webappdirectory parameter.
<Project> ... <Build> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-war-plugin</Artifactid> <version>3.0.0</version> <Configuration> <webappdirectory>/sample/servlet/container/deploy/directory</webappdirectory> </Configuration> </plugin> </Plugins> </Build> ...</Project>
- Calling mvn compile War:inplace, the unpackaged War folder is created under src/main/webapp/ .
Summary : 4 ways to call, but the actual effect is 3, the difference is that the final creation is the file or folder, where to create (target/, src/main/webapp/).
Official Documentation Links:
Http://maven.apache.org/plugins/index.html
Maven Learning Plugin Plugin