In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the life cycle and plug-ins of Maven". The content of the explanation is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the life cycle and plug-ins of Maven".
A complete project construction process usually includes cleaning, compilation, testing, packaging, integration testing, verification, deployment and other steps, from which Maven extracts a complete and scalable life cycle. The life cycle of Maven is abstract, in which the specific tasks are left to plug-ins to complete. Maven writes and binds default plug-ins for most build tasks, such as for compiled plug-ins: maven-compiler-plugin. Users can also configure or write plug-ins themselves.
1. Three sets of life cycle
Maven defines three sets of life cycles: clean, default, and site, each of which contains phases (phase). The three lifecycles are independent of each other, but the phase in each lifecycle is sequential, and the subsequent phase depends on the previous phase. When a phase is executed, the preceding phase executes sequentially, but does not trigger any phase in the other two lifecycles.
1. 1 clean Lifecycle
Pre-clean: perform the work before cleaning up
Clean: clean up all files generated by the last build
Post-clean: perform the work after cleaning up
1. 2 default Lifecycle
The default life cycle is at the core, containing all the steps that really need to be performed when building a project.
Validate
Initialize
Generate-sources
Process-sources
Generate-resources
Process-resources: copy and process resource files to the target directory, ready to package
Compile: compile the source code of the project
Process-classes
Generate-test-sources
Process-test-sources
Generate-test-resources
Process-test-resources
Test-compile: compile test source code
Process-test-classes
Test: running test code
Prepare-package
Package: distribution packages packaged in jar or war or other formats
Pre-integration-test
Integration-test
Post-integration-test
Verify
Install: install the packed package to the local warehouse for use by other projects
Deploy: install the packed package to the remote warehouse for use by other projects
1. 3 site Lifecycle
Pre-site
Site: generate site documentation for the project
Post-site
Site-deploy: publish generated site documents
2. Plug-ins for Maven
The core file of Maven is very small, and the main tasks are accomplished by plug-ins. Navigate to:% local warehouse%\ org\ apache\ maven\ plugins, and you can see some downloaded plug-ins:
A more detailed list of official plug-ins is available on the Maven website:
What are the goals of each plug-in? the official documentation describes it in more detail: Maven Plugins
3. 1 built-in binding
Maven binds plug-in goals to some phases of the lifecycle (phase) by default, because different projects have different packaging methods, such as jar, war, pom, etc., so they have different binding relationships. The binding relationships of jar packages for default lifecycle are as follows:
In the second column, the colon is followed by the binding plug-in target, and the colon is preceded by the plug-in prefix (prefix), which is a simplified way to configure and use the plug-in. Plugin Prefix
3. 2 Custom binding
Users can bind any plug-in target to any stage of the lifecycle as needed, for example, bind the jar-no-fork target of maven-source-plugin to the package phase of the default lifecycle, so that when you execute the mvn package command to package the project later, the source code package will be executed after the package phase to generate a source code package such as: ehcache-core-2.5.0-sources.jar.
Org.apache.maven.plugins maven-source-plugin 2.2.1 attach-source package jar-no-fork.
4. Configure plug-in
The Maven plug-in is highly extensible and can be easily customized. For example, configure the JDK version of the compiled source code of the maven-compiler-plugin plug-in to be 1.7:
Org.apache.maven.plugins maven-compiler-plugin 1.7 1.7
You can also configure each target of the plug-in more specifically. Configuring Plug-ins
5. Plug-in warehouse
Like other artifacts, plug-ins are stored in the Maven repository based on coordinates. The default plug-in remote repository for Maven configuration in Super POM is as follows:
Central Central Repository http://repo.maven.apache.org/maven2 default false never thank you for reading, this is the content of "what is the life cycle of Maven and plug-ins". After the study of this article, I believe you have a deeper understanding of the life cycle of Maven and what plug-ins are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.