The most recent projects have been in the use of maven , but be aware that the earliest build tools are Ant , and now Ant There are still a lot of people to use, so they drew out time, study a bit Ant the basic use of the. This also helps to understand the new features that Maven offers.
First, let's talk about their respective roles:
Ant The role of: is based on the build tool for Java
- Java classes can be compiled with ant to generate class files
- Ant can customize tags, configuration files, and build.
- ant can build the relevant layer into Jar package.
- Ant builds the entire project into a Web package and publishes it to Tomcat
Benefits of Ant:
- < Span style= "font-size:10.5pt" > cross-platform: ant java language is written so that it has a good cross-platform nature.
- simple operation: ant is made up of a built-in task and optional tasks. ant runtime requires a xml file Span style= "FONT-FAMILY:CALIBRI; Font-size:10.5pt "> ( build file )
- < Span style= "font-size:10.5pt" >ant target task : each task ant When you build the file xml format files, So it is easy to maintain and write, and the structure is very clear.
- Ant can be integrated into the development environment: because Ant of cross-platform and simple operation, it is easy to integrate into some development environment.
Maven role: In addition to the ability to build a program to feature, but also provide advanced project management tools.
Maven in addition to having Ant features, the following main features are added:
- Use Project Object Model to the software project management;
- Built-in more implicit rules, making it easier to build files;
- built-in dependency management and Repository to achieve dependency management and unified storage;
- Built-in software build life cycle;
Maven The advantages of:
- Have a contract to know where your code is and where to put it
- have a life cycle, such as executing mvn Install You can automate the build process such as compiling, testing, packaging, etc.
- you only need to define a Pom.xml, then the source is stacked to the default directory, Maven To help you with other things .
- have dependency management, warehouse management
The overall comparison:
Antwill provide a lot of reusableTask, such ascopy, move, deleteas wellJUnitUnit TestMavenprovides a number of processes that can be reused. we can putMavenseen as a"Build Container"This container allows us to reuse the images from a series of projects .Buildprocess.
have usedAntfriends will have this experience. Antprovided byTasklevel description that we can write by thinkingShellas aJavaof the projectBuildprocedure to describe the process. We can write a goodBuild.xmlfiles, to solve ourJavaThe program needs to be resolved during the compilation process.Classpath, and the configuration of the relevant parameters, only the main structure of the project and the dependent libraries are not changed, we seldom modifyBuild.xml. But if we're going to develop a new project, even if the original projectBuild.xmleven if the writing is good, it can reuse the module is still relatively small. In particular, after modifying the structure of the project, I do not want to modifyBuild.xmlare very difficult. this is becauseAntThe provided reusableTaskThe granularity is too small, although the flexibility is strong, but we need to dwell on a lot of details of things.
as you are usingServletcontainer, and did not tell it how to unpack the packageWARfiles that you use inMaven, you don't have to tellMavenHow toBuildyour project. Mavenprovides a set of abstraction layers for separating projectsBuildlogic. A lot of people were initiallyMavenThe provided dependency management (which can beXMLto describe the relationship of the library on which the project depends), but useMavenThe main benefit is that it can be used to manage multiple projects to provide a standard development framework. Dependency Management is just a byproduct of this standard development architecture.
if you want to makeMavenImplement aBuildprocesses, such ascompile, test, install, we can write bypluginthe way it is easy to implementBuildreuse of the process. Mavencan provide us with a very comfortableBuildenvironment, we do not need to passBuild.xmldefine the tediousBuildProcess,just need to tell theseBuildprocess ofplugin,my current file depends on those third-party libraries that I need to implement what kind ofBuildfunction, it's enough.. These cumbersome path configuration information, as well as complex third-party library download settings, you do not have to consider,Mavenand it'spluginhave helped you to achieve it.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The difference between Maven and Ant