Apache Maven java build tool?

Maven is a widely used build management tool. Apache Software Foundation maintains maven in java programming language. So a lot of java projects use maven as build management tool. Maven follows the paradigm convention over configuration. This reduces complexity in software projects. In other words, following conventions reduces setup.

Maven manages file artifacts

Maven manages file artifacts used during build process. These artifacts are build and run time resources. Such resources are stored to local disk. The resource path contains elements like groupId, artifactId or version. Such tuple of elements makes an file artifact unique. Optional the path may contain additional elements, e.g. a classifier. All elements of artifact file path in combination are unique. A java project uses a lot of jar-dependencies. An unique identifier references any required jar resource.

Maven ensures that artifact is present on local disk. Also internet archives store many jar artifacts. So maven loads missing artifacts from internet. During maven build process all required resources are copied to local disk. Once loaded, maven requires no access to internet. So at very first build step internet access happens. Any further build process will use local existing resources. Target of a build process may be an artifact, too. So maven copies self generated artifacts to the local disk. Artifacts are beside artifacts from internet.


Maven project object model

Project object model represents a project setup. Maven uses this model for building a maven project. So setup of pom.xml file defines a new maven project. As mentioned, maven follows paradigm convention over configuration. So configuration focuses project specifics only. Using predefined directories and settings simplifies pom definition. The maven pom derives its initial settings from parent pom. Maven comes with master pom. A custom pom definition may replace maven defaults. A project pom defines differences to parent pom.

Examples for pom settings are:

  • target id of current project (groupId, artifactId, version)
  • dependencies
  • plugin settings (e.g. java compiler)
  • packaging (e.g. jar, war, ear)
  • source directory (src/main/java is default, only differences to default must be specified)
  • parent definitions
  • sub modules

Maven Repository

The repository uses file- and folder name conventions to archive severals version of an atrifact. There a two versions of maven repositories, the local and the remote repository.

The local maven installation uses the local repository to build a given pom project. Maven fetches missing artifacts from remote repositories and adds the to the local repository. In this way maven ensures that all required artifacts are located on local workstation. In this way the local repository acts like an cache. When deleting the cache the next maven build must fetch artifacts from remote. This may take a while.

Remote repositories are usually persistent. They do not act like a cache and are well managed. Most popular repository is central managed by apache foundation. The central repository contains all maven core modules and most apache projects. Other companies manage their own repositories, e.g. jboss or spring. A company can also host its own maven repository to archive their artifacts.