Coordinates: groupId, artifactId, version, packaging

A Maven project is identified by four values that fit in one line: groupId:artifactId:packaging:version. They are not decoration: the same four values appear in every build log, in the name of the jar and in the path where the artifact is installed, and a project that gets them wrong is found in the wrong place by the next project. This article follows them through one install.

The four values

pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example.store</groupId> <artifactId>coords</artifactId> <version>2.3.1</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>21</maven.compiler.release> </properties> </project>

src/main/java/com/example/coords/Coords.java

package com.example.coords; public class Coords { public static void main(String[] args) { System.out.println("2.3.1"); } }

In the build log

mvn install builds the jar and puts it into the local repository, and its log prints the coordinates twice before it does anything:

mvn -B install > build.log 2>&1; echo "status: $?"; sed "s#$PWD#<project>#g" build.log

status: 0
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.example.store:coords >----------------------
[INFO] Building coords 2.3.1
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.4.0:resources (default-resources) @ coords ---
[INFO] skip non existing resourceDirectory <project>/src/main/resources
[INFO]
[INFO] --- compiler:3.15.0:compile (default-compile) @ coords ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [debug release 21] to target/classes
[INFO]
[INFO] --- resources:3.4.0:testResources (default-testResources) @ coords ---
[INFO] skip non existing resourceDirectory <project>/src/test/resources
[INFO]
[INFO] --- compiler:3.15.0:testCompile (default-testCompile) @ coords ---
[INFO] No sources to compile
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ coords ---
[INFO] No tests to run.
[INFO]
[INFO] --- jar:3.5.0:jar (default-jar) @ coords ---
[INFO] Building jar: <project>/target/coords-2.3.1.jar
[INFO]
[INFO] --- install:3.1.4:install (default-install) @ coords ---
[INFO] Installing <project>/pom.xml to <HOME>/.m2/repository/com/example/store/coords/2.3.1/coords-2.3.1.pom
[INFO] Installing <project>/target/coords-2.3.1.jar to <HOME>/.m2/repository/com/example/store/coords/2.3.1/coords-2.3.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.943 s
[INFO] Finished at: 2026-11-22T08:31:21Z
[INFO] ------------------------------------------------------------------------

The dashed line is built from the first two coordinates and the artifact id, < com.example.store:coords >, and it is padded to the width of the longest line of the block. Building coords 2.3.1 is the artifact id and the version, and the brackets at the end of the block name the packaging: [ jar ]. The two Installing lines show where the four values put the files.

In target and in the jar name

Inside the project the artifact id and the version name the jar and nothing else:

ls -1 target/

classes
coords-2.3.1.jar
generated-sources
maven-archiver
maven-status

coords-2.3.1.jar is <artifactId>-<version>.jar; the finalName element of the build changes that name, and a name that does not follow the pattern is a surprise for every tool that reads target. generated-sources holds what an annotation processor writes; this project has none, so the folder is empty and ls does not list it.

In the local repository

The local repository turns the group id into folders, then the artifact id, then the version:

find ~/.m2/repository/com/example/store -type f | sort | sed "s#$HOME#~#g"

~/.m2/repository/com/example/store/coords/2.3.1/_remote.repositories
~/.m2/repository/com/example/store/coords/2.3.1/coords-2.3.1.jar
~/.m2/repository/com/example/store/coords/2.3.1/coords-2.3.1.pom
~/.m2/repository/com/example/store/coords/maven-metadata-local.xml

The path is the reason the local repository article can show a tree and the reason a second project finds this jar: it looks for com.example.store:coords:2.3.1, builds the same path and takes what is there. The module article does exactly that with a separate project.

Packaging

packaging decides what the package phase produces and which goals the phases before it run. The four a beginner meets:

A project that changes its packaging changes the artifact it installs, not its coordinates: com.example.store:coords:2.3.1 can be a jar today and a pom tomorrow, and a consumer that asks for the jar of a pom gets an error instead of a file. The lifecycle article shows the goals behind each packaging.

Where to go next

Properties shows how a value is written once in the pom and read in several places, and the effective pom shows the coordinates as Maven resolves them, with the parents and the defaults already applied.

Article author: Arthur Isaev