Maven Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 19: Line 19:
===Artifact Name===
===Artifact Name===


The artifactId is used to generate the project's artifact name, according to the pattern <tt></tt>.
The artifactId is used to generate the project's artifact name, according to the pattern <tt>artifactId-version.packaging</tt>.


The name can be overridden using the [[Maven_pom.xml#.3CfinalName.3E|finalName element]].
The name can be overridden using the [[Maven_pom.xml#.3CfinalName.3E|finalName element]].

Revision as of 16:21, 18 November 2016

Internal

Maven Coordinates

groupId:artifactId:version is the minimum amount of information to fully and unequivocally identify an artifact, and constitute an address and a timestamp. This information is referred to as maven coordinates. More details about each component below.

Group ID

The group ID is an unique identifier (ideally, globally) for a project. It is specified as <groupId> at the top of the POM file.

Conventionally uses a dot notation, but it does not have to. When it does use the dot notation, the groupId does NOT have to correspond to the package structure of the project it designates; it is, though, a good practice to follow. When stored within a repository, the dots are replaced by OS specific directory separators, which becomes a relative directory structure from the base repository.

Artifact ID

The artifact ID is generally the name that the project is known by. It is specified as <artifactId> at the top of the POM file. The artifact ID, along with the group ID, create a key that ideally separates this project from every other project in the world.

Artifact Name

The artifactId is used to generate the project's artifact name, according to the pattern artifactId-version.packaging.

The name can be overridden using the finalName element.

Version

The version represents a timestamp for a specific incarnation of the project's artifact, in the history of the project. The information is used within an artifact's repository to separate versions from each other. It is specified as <version> at the top of the POM file.

For more details on a project's module version management, see "Modules and Versions" section.

Packaging

The packaging represents the project's artifact type. It is specified as <packaging> at the top of the POM file.

When no packaging is declared, Maven assumes the artifact is, by default, a "jar". The valid types are Plexus role-hints of the component role org.apache.maven.lifecycle.mapping.LifecycleMapping. The current core packaging values are: "pom" (for an example see multi-module projects), "jar", "maven-plugin", "ejb", "war", "ear", "rar" and "par". These define the default list of goals which execute to each corresponding build lifecycle stage for a particular package structure.

If you need to specify packaging in the Maven coordinates of a project, it is specified after artifact ID: groupId:artifactId:packaging:version.

Classifier

The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.

A common use case for classifiers is the need to attach secondary artifacts to the project's main artifact (for example, javadocs or sources).

It is specified as <classifier> at the top of the POM file. If you need to specify the classifier in the Maven coordinates of a project, it is specified after packaging: groupId:artifactId:packaging:classifier:version.

Classifiers are also used by the assembly plugin.

Name

It is specified as <name> at the top of the POM file.

Type

POM

pom.xml

Profile

Maven Profile

Lifecycle

Maven Lifecycle

System Properties

System properties can be declared and exposed to the build in the <properties> section of pom.xml. See:

pom.xml <properties>

Dependencies

Maven Dependencies

Repositories

Maven Repositories

Multi-Module Maven Projects

Multi-Module Maven Projects

Fileset

Maven FileSets

System Properties

Maven Standard System Properties
Maven Custom System Properties