Chapter 1. Apache Maven – Introduction and Installation

"A journey of a thousand miles starts with a single step", Lao Tzu. Rightly so, if you are reading this sentence here, you have taken a step towards a journey of Maven with Eclipse. As part of this journey, in the very first chapter, we will introduce you to Maven and its basic architecture and then guide you through the installation process through the following subtopics:

  • Introduction to Maven
  • Maven's origin
  • Maven's principles
  • Maven's component architecture
  • Maven versus Ant
  • Downloading Maven
  • Installing Maven
  • Installing Maven on Windows
  • Installing Maven on Linux and Mac OS
  • Verifying the installation of Maven

Introduction to Maven

Apache Maven's official site states that Apache Maven, which is also known as Maven, is a software project management and comprehension tool. Generally, software project management comprises planning, organizing, managing resource pools, and developing resource estimates; hence, it is a meaningless abstraction to justify Maven offerings. To put it in simple words, Maven is a comprehensive approach towards the process of applying patterns to a build infrastructure with primary goals as follows:

  • Easing the build process
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practice development
  • Allowing transparent migration to new features

In order to achieve the preceding goals, Maven provides a set of build standards, an artifact repository model, an engine that describes projects, and a standard lifecycle to build, test, and deploy project artifacts.

Maven's origin

Maven, a Yiddish word that means accumulator of knowledge, was initially started as an attempt to simplify the build processes in the Jakarta Turbine project. Prior to Maven, Ant was the build tool used across projects, and there were different Ant build files across different projects. Also, there were no standard or consistent Ant build files for projects, and JARs were also required to be checked in subversion. Hence, there was a growing necessity to standardize the project's build process and its structure, publish project information, and reuse JARs across projects, which resulted in the formation of a new tool, Maven. Maven has made the day-to-day work of developers easy, and it provides comprehension of any Java project.

Maven's principles

Maven's principles can be stated in the following points:

  • Convention over configuration: Maven defines the default project structure and builds a life cycle that eases the burden during development. By specifying a publicly defined model, it makes the project more understandable.
  • Declarative execution: Maven defines a build life cycle that comprises phases, which in turn are made up of plugin goals. Plugins and goals can be included declaratively in the pom file to customize the execution of a project.
  • Reusability: Maven was built with reusability in mind. The build and execution declaration in one project can be used across different projects. Maven also makes it easier to create a component and integrate it into a multiproject build system. Also, with Maven Best Practices, development across the industry is encouraged.
  • Coherent organization of dependency: Maven takes care of dependency management, thus reducing the burden on the part of developers. Different conflicts across dependencies are also handled beautifully.
  • Focus on writing applications: With a standard project layout and build lifecycle, there is no need to develop the build; the focus should primarily be on building the application.

Maven's component architecture

Maven is built around different components as shown in the following diagram:

Maven's component architecture

Maven component architecture (Reference Apache Team Presentation)

The Plexus container

Plexus is an IOC container that provides component-oriented programming to build modular, reusable components that can be easily assembled and reused. Some of the features supported are as follows:

  • Component lifecycles
  • Component instantiation strategies
  • Nested containers
  • Component configuration
  • Auto-wiring
  • Component dependencies
  • Various dependency injection techniques, including constructor injection, setter injection, and private field injection

Note

More information on this can be found at http://plexus.codehaus.org/.

Wagon

Maven Wagon is a transport abstraction used in the Maven artifact and repository-handling code. Wagon defines a unified API, and it currently has the following providers:

  • File
  • HTTP
  • HTTP lightweight
  • FTP
  • SSH/SCP
  • WebDAV

Note

More information on this can be found at https://maven.apache.org/wagon/.

Maven Doxia

Doxia is a content generation framework that provides users with powerful techniques to generate static and dynamic content. Doxia is also used in a web-based publishing context to generate static sites, in addition to being incorporated into dynamic content generation systems such as blogs, wikis, and content management systems.

Note

For more information on Maven Doxia, refer to https://maven.apache.org/doxia/.

Modello

The Modello component in Maven can be used to generate the following types of artifacts at build time with reference to the data model:

  • Java POJOs of the data model
  • Java POJOs to XML
  • XML to Java POJOs
  • Xdoc documentation of the data model
  • XML schema to validate that XML content matches the data model

Note

For more information, refer to http://maven.apache.org/maven-1.x/plugins/modello/.

Maven SCM

This component provides a common API to perform Source Code Management (SCM) operations. The following type of SCMs are supported:

  • Bazaar
  • CVS
  • Git
  • Jazz
  • Mercurial
  • Perforce
  • StarTeam
  • Subversion
  • CM energy

Note

More information is available at http://maven.apache.org/scm/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.242.235