Build Maven in Linux

Source: Internet
Author: User

MavenIs a software project management tool based on the project Object Model (POM). It uses a short description to manage project construction, reports, and documents.

Currently, most developers use ant as a standard building tool for Java programming projects. However, ant's project management tool (as an alternative to make) cannot meet the needs of most developers. By checking ant build files, it is difficult to find the relevance information and other metadata of the project (such as the developer/owner, version, or site homepage ).

In addition to program building capabilities, Maven also provides advanced project management tools that ant lacks. Because Maven's default build rules are highly reusable, it is often possible to build a simple project using two or three lines of Maven build scripts, while ant requires more than a dozen lines. In fact, due to Maven's project-oriented approach, many Apache Jakarta projects now use Maven, and the proportion of Maven used by corporate projects continues to grow.

The word Maven comes from the yidixu language, which indicates the accumulation of knowledge. It was first used in the jakata turbine project to try to simplify the building process. At that time, there were many projects whose ant build files were only slightly different, while jar files were maintained by CVS. The creator of Maven started the maven project. The clear definition of this project includes a convenient way to publish project information and a way to share jar among multiple projects.

What is the difference between Maven and ant?

Ant provides cross-platform build tasks for Java technology development projects

Maven itself describes the high-level aspects of the project. It borrows the vast majority of build tasks from ant.

Maven

Ant

Standard Build File

Project. xml and maven. xml

Build. xml

Feature processing sequence

$ {Maven. Home}/bin/driver. Properties

$ {Project. Home}/Project. Properties

$ {Project. Home}/build. Properties

$ {User. Home}/build. Properties

The-D command line option defines the system features, and the last definition determines the role.

System features defined using the-D command line option

Features loaded by <property> tasks

The first definition is first processed.

Build rules

Building rules are more dynamic (similar to programming languages); they are jelly-based executable XML.

Building rules are more or less static unless you use a <SCRIPT> task.

Extended Language

The plug-in is written in jelly (XML.

The plug-in is written in Java.

Build rule scalability

Define <pregoal> and <postgoal> to make the build goal extensible.

Building rules are not easy to expand. You can use the <SCRIPT> task to simulate <pregoal> and <postgoal> roles.

Maven and ant represent two very different tools.

1. Download

Official: maven_download, latest apache-maven-3.0.5-bin.tar.gz

Official Address: Maven

2. Extract

Tar zxvf apache-maven-3.0.5-bin.tar.gz (for example, the installation directory is/home/Homer/Apache-Maven/apache-maven-3.0.5)

3. Install

1) edit/etc/profile

Sudo VI/etc/profile

2) Configuration

Configure the maven installation directory:

ExportMaven_home=/Home/Homer/Apache-Maven/apache-maven-3.0.5 // installation directory

Export path =$ {maven_home}/bin: $ {path}


For example:

3) Effective

Source/etc/profile // make the above configuration take effect

4. Verification

Command Line input: MVN-V

For example, if the maven version information is displayed, the installation is successful!

Note:

When eclipse updates Maven, it accidentally shakes hands and clicks disable Maven nature. Then the maven bar in the right-click menu of the Project will disappear!

In fact, this is to convert the maven project into a general project and then turn it back.

To convert a Maven project to a general project, right-click the project ---> Maven ---> disable Maven nature to a general project.

To convert a project to a Maven project, right-click the project and choose "---> Configure --->" convert to Maven project "to convert it to a Maven project.

Reference recommendations:

Maven (official)

Ant (official)

Introduction to common Maven commands

Full introduction to MVN

Maven Getting Started Guide (official command)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.