본문 바로가기

Maven

 

Developer(s)

Apache Software Foundation

Initial release

July 13, 2004 (15 years ago)

Stable release

version : 3.6.1 / 4 April 2019 (48 days ago)

Repository

https://gitbox.apache.org/repos/asf?p=maven.git

Written in

Java

Type

Build tool

License

Apache License 2.0

Website

maven.apache.org 


Apache Maven is a dependency management and a build automation tool, primarily used for Java applications.


Why?

 Maven uses a declarative approach, where the project structure and contents are described, rather then the task-based approach used in Ant or in traditional make files, for example. This helps enforce company-wide development standards and reduces the time needed to write and maintain build scripts.

 Maven was born of the very practical desire to make several projects at Apache work in the same way. So that developers could freely move between these projects, knowing clearly how they all worked by understanding how one of them worked. If a developer spent time understanding how one project built it was intended that they would not have to go through this process again when they moved on to the next project. The same idea extends to testing, generating documentation, generating metrics and reports, testing and deploying. All projects share enough of the same characteristics, an understanding of which Maven tries to harness in its general approach to project management. On a very high level all projects need to be built, tested, packaged, documented and deployed. Of course there is infinite variation in each of the above mentioned steps, but this variation still occurs within the confines of a well defined path and it is this path that Maven attempts to present to everyone in a clear way. The easiest way to make a path clear is to provide people with a set of patterns that can be shared by anyone involved in a project.

 

 

What?

 Maven is used for project build automation using Java. It helps you map out how a particular software is built, as well as its different dependencies. It uses an XML file to describe the project that you are building, the dependencies of the software with regards to third-party modules and parts, the build order, as well as the needed plugins. There are pre-defined targets for tasks such as packaging and compiling.

 Maven will download libraries and plugins from the different repositories and then puts them all in a cache on your local machine. While predominantly used for Java projects, you can use it for Scala, Ruby, and C#, as well as a host of other languages.

 

 

Pros

 Making the build process easy

 Providing a uniform build system

 Providing quality project information

    1. Change log document created directly from source control

    2. Cross referenced sources 

    3. List of mailing lists managed by the project 

    4. Dependency list 

    5. Unit test reports including coverage

 Providing guidelines for best practices development

    1. Keeping test source code in a separate, but parallel source tree

    2. Using test case naming conventions to locate and execute tests

    3. Having test cases setup their environment instead of

                                   relying on customizing the build for test preparation

 Allowing transparent migration to new features

 

 

How to work?

1. Read pom.xml file

2. Downloads dependecies defined in pom.xml into local repository form central or remote repository

3. Execute life-cycles, phases, goals, plugins etc. defines in specifies build path.

 

 

Concepts

● Project Object Model

   - A Project Object Model (POM) provides all the configuration for a single project. General configuration covers the project's name, its owner and its dependencies on other projects.

● Plugins

   - Most of Maven's functionality is in plugins.

● Build lifecycles

   - Build lifecycle is a list of named phases that can be used to give order to goal execution.

● Dependencies

   - A central feature in Maven is dependency management. Maven's dependency-handling mechanism is organized around a coordinate system identifying individual artifacts such as software libraries or modules.

 

 

The directory structure of a normal idiomatic Maven project

Directory name : Purpose

project home

 : Contains the pom.xml and all subdirectories.

 

 

src/main/java

 : Contains the deliverable Java sourcecode for the project.

src/main/resources

 : Contains the deliverable resources for the project, such as property files.

 

 

src/test/java

 : Contains the testing Java sourcecode (JUnit or TestNG test cases, for example) for the project.

src/test/resources

 : Contains resources necessary for testing.

 

 

 

 

Example

refer to Link)

● Maven - Introduction
https://maven.apache.org/what-is-maven.html
● Apache Maven - Wikipedia
https://en.wikipedia.org/wiki/Apache_Maven
● 아파치 메이븐 - 위키백과
https://ko.wikipedia.org/wiki/%EC%95%84%ED%8C%8C%EC%B9%98_%EB%A9%94%EC%9D%B4%EB%B8%90
● Introduction to Apache Maven
https://www.geeksforgeeks.org/introduction-apache-maven-build-automation-tool-java-projects/
● An introduction to Maven 2
https://www.javaworld.com/article/2072203/an-introduction-to-maven-2.html
● Gradle vs. Maven - DZone Java
https://dzone.com/articles/gradle-vs-maven

● [키워드정리 15편] maven
https://blog.naver.com/jungi__/221519278935
● Maven vs. Ant : Adam Bien's Weblog
https://www.geeksforgeeks.org/introduction-apache-maven-build-automation-tool-java-projects/

'Theory > Build Tool' 카테고리의 다른 글

Ant vs Maven vs Gradle (Comparison)  (0) 2019.05.03
Gradle  (0) 2019.05.02
Ant  (0) 2019.04.30