Simple understanding of Maven

1. The concept of
  Maven : Maven is a tool for project construction, dependency management, and project information aggregation. It provides methods to help manage build, documentation, reports, dependencies, release, and distribution. You can easily compile code, perform dependency management, manage binary libraries, and so on. As an open source project of Apache, Maven aims to provide more support for project management. Its original intention is to provide unified development, testing, packaging and deployment for several projects organized by Apache, allowing developers to work in multiple projects. Convenient switching in the project. The advantage of Maven lies in the standardization, automation, efficiency and strong scalability of the project process. Using maven itself and its plug-ins can also obtain code inspection reports, unit test coverage, continuous integration, and so on.
  2. Maven's build life cycle:
  Maven abstracts and defines the build process. This process is called the build life cycle.
  The construction lifecycle (lifecycle) is composed of multiple phases, each phase will be linked to one or more goals, and the goal is the smallest unit of task definition in maven, which is equivalent to the target in ant. It can be understood that maven is a container of plugins, and each plugin is bound to a certain goal for execution.
  For example, the default life cycle includes the following stages:
    validate-verify that the project is correct and all necessary information can be
    compiled (compile)-compiled project source code
    testing (test)-tested with a suitable unit testing framework Compiled source code. These tests should not require the code to be packaged or deployed
    -take the compiled code and package it in its distributable format (such as JAR).
    Verify-Perform any checks on the results of integration tests to ensure that quality standards are met
    Install-install the package into the local repository, and use it as a dependency of other local projects.
    Deployment (deploy)-complete in the build environment, copy the final package to the remote repository to communicate with other developers and projects shared.
    These life cycle phases (and other life cycle phases not shown here) are executed in sequence to complete the default life cycle. Given the above lifecycle stages, this means that when using the default lifecycle, Maven will first verify the project, then try to compile the source code, run these source codes, package the binary files (eg jar), run the integration test package, and verify the integration Test, install the verified package to the local repository, and then deploy the installed package to the remote repository.
In other words, the stages in the life cycle are continuous. Under the premise of no error, for example, when the package is executed, it must be executed after the test is executed.

Stages of the default life cycle description
verification Ensure that the current configuration and the contents of the POM are valid. This includes the pom. Validation of xml file tree
initialization It can be initialized before executing the main task of the build life cycle.
Generate source code The code generator can start to generate source code to be processed or compiled in a later stage.
Processing source code Provide analysis, modification and conversion of source code. Both regular source code and generated source code can be processed here
Generate resources Can generate non-source code resources. Usually includes metadata files and configuration files.
Processing resources Deal with non-source code resources. Modification, conversion, and relocation of resources all happen at this stage.
Compile Compile the source code. The compiled class is placed in the target directory tree.
Processing class Process file conversion and enhancement steps. Bytecode interleaver and common tools operate at this stage
Generate test source code mojo can generate unit test code to operate.
Processing test source code Perform any necessary processing on the test source code before compiling. At this stage, the source code can be modified, converted or copied
Generate test resources Allows generation of test-related resources
Handling test resources Can handle, transform and relocate resources related to testing.
Test compilation Edit the source code of the unit test.
Processing test code Process the test code.
test Run the compiled unit tests and accumulate the results.
Preparation before packing Preparation before packing
Bale Package the executable binary file into a distributed archive file.
Pre-integration test Prepare for integration testing.
Integration Testing Perform real integration testing.
Post-integration test Release the integration test preparation.
test Test the validity and completeness of deployable archives.
installation Add the archive to the local Maven directory.
deploy Add the archive to the remote Maven directory.

Guess you like

Origin blog.csdn.net/qq_43631037/article/details/94409067