What is maven?

小樹木發表於2021-06-18

Introduction

Maven, a Yiddish word meaning accumulator(累加器) of knowledge, began as an attempt to simplify the build processes in the Jakarta Turbine project. There were several projects, each with their own Ant build files, that were all slightly different. JARs were checked into CVS. We wanted a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information, and a way to share JARs across several projects.

 

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend(理解) the complete state of a development effort(工作) in the shortest period of time. In order to attain this goal, Maven deals with several areas of concern:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Encouraging better development practices

Making the build process easy

While using Maven doesn’t eliminate(排除) the need to know about the underlying mechanisms(機制), Maven does shield(遮蔽) developers from many details.

雖然使用 Maven 並不能消除了解底層機制的需要

 

Providing a uniform build system

Maven builds a project using its project object model (POM) and a set of plugins. Once you familiarize yourself with one Maven project, you know how all Maven projects build. This saves time when navigating many projects.

Providing quality project information

Maven provides useful project information that is in part taken from your POM and in part generated from your project’s sources. For example, Maven can provide:

  • Change log created directly from source control(改變log建立的路徑)
  • Cross referenced sources(交叉引用來源)
  • Mailing lists managed by the project
  • Dependencies used by the project
  • Unit test reports including coverage

Third party code analysis products also provide Maven plugins that add their reports to the standard information given by Maven.

Providing guidelines for best practices development

Maven aims to gather current principles for best practices development and make it easy to guide a project in that direction.

For example, specification, execution, and reporting of unit tests are part of the normal build cycle using Maven. Current unit testing best practices(實踐) were used as guidelines:

  • Keeping test source code in a separate(分離), but parallel source tree(並行源樹)
  • Using test case naming conventions(公約) to locate and execute tests
  • Having test cases setup their environment instead of customizing(定製) the build for test preparation
  • 讓測試用例設定他們的環境,而不是為測試準備定製構建

Maven also assists in project workflow such as release and issue management.

Maven also suggests some guidelines(指導方針) on how to layout your project’s directory structure. Once you learn the layout, you can easily navigate other projects that use Maven.

While takes an opinionated approach to project layout, some projects may not fit with this structure for historical reasons. While Maven is designed to be flexible to the needs of different projects, it cannot cater to every situation without compromising its objectives.

If your project has an unusual(異常) build structure that cannot be reorganized, you may have to forgo some features or the use of Maven altogether(完全 adv.).

What is Maven Not?

You might have heard some of the following things about Maven:

  • Maven is a site and documentation tool
  • Maven extends Ant to let you download dependencies
  • Maven is a set of reusable Ant scriptlets
  • Maven 是一組可重用的 Ant 指令碼

While Maven does these things, as you can read above in the “What is Maven?” section, these are not the only features Maven has, and its objectives(目標) are quite different.

 

相關文章