What is maven? What's the use?
MAVEN is a project management tool that contains
- A Project object model,
- A set of standard sets,
- A Project life cycle (ProjectLifecycle),
- A dependency management system (Dependency Management systems),
- The logic used to run the plug-in (plugin) target (goal) defined in the life cycle phase (phase).
When you use MAVEN, you use a well-defined project object model to describe your project, and Maven can apply crosscutting logic that comes from a set of shared (or custom) plug-ins.
The contract is better than the Config (Convention over configuration)
The contract is better than the configuration is a simple concept. System, Class library, the framework should assume a reasonable default value to simplify the configuration when used, while preserving the user's right to modify the default configuration. However, in most cases, you will find that using the default values provided by the framework will make your project run faster or more convenient.
In Maven, where there is no customization, the directory is generally as follows,
- The source code is in/myapp/src/main/java,
- The resource file is in/myapp/src/main/resources,
- The test code is in/myapp/src/test;
The project will produce a JAR file. MAVEN will put
- Compiled bytes are stacked to/myapp/target/classes
And
- Create a distributable jar file to be placed in the/myapp/target.
Global reusability based on MAVEN plug-in
The core of Maven is not actually doing anything, except parsing some XML documents, managing the lifecycle and plugins, and it doesn't know anything.
MAVEN is designed to delegate the primary responsibility to a set of Maven plugins that can affect the MAVEN lifecycle and provide access to the target. The overwhelming majority of MAVEN actions occur in the Maven plugin's target, such as compiling source code, packaging binaries, publishing sites, and other build tasks. The maven you downloaded from Apache doesn't know how to pack the WAR files, or how to run unit tests, most of MAVEN's intelligence is implemented by plug-ins, and plugins are available from the MAVEN repository.
In fact, the first time you run a new MAVEN installation like the MVN Install command, it downloads most of the core MAVEN plugins from the central Maven repository. This is not just a trick to minimize the size of the Maven bundle, which allows you to upgrade your plugins to build your project.
The fact that Maven gets dependencies and plug-ins from a remote repository allows for global reuse of the build logic.
Here, for example, to unit test for example, originally your project unit test is based on Junit3 write, the original run unit test plug-in version (Maven Surefire) can only execute junit3, and then out of JUNIT4, decisive you replaced the support annotated JUNIT4, So the problem comes, the original version of Maven Surefire does not support, need to upgrade the new version, the general practice is to upgrade the plug-in, all kinds of trouble, after using MAVEN, only need to modify the version number in the Pom, it is so simple.
Maven Abstracts General build tasks into plug-ins, which are well maintained and shared globally, so you don't need to customize your project's build system from scratch and then provide support.
The difference between Maven and Ant
Not knowing about Ant, a little of what's in the MAVEN's authoritative guide is not enough to give me a complete understanding of ant,
From my own understanding, the biggest difference is that the MAVEN convention is better than the configuration: Maven contracts which directory to do, and ant needs to be configured.
Draw upon the answers of the Great gods (author Sunboy, source http://www.linuxidc.com/Linux/2013-05/84489.htm):
MAVEN's authoritative Guide to learning Notes (i)--Introduction