skip to content

Coordinates & Packaging

GAV coordinates, packaging types, classifiers, and what a SNAPSHOT version actually means to a repository. A staple question, because 'why does my SNAPSHOT keep changing?' has a precise answer here.

on this pageshow

questions

6

What are Maven coordinates (GAV), and what does each part identify?

level: juniorimportance: must knowfreq 80%

answer

  1. groupId = reverse-DNS namespace
  2. artifactId = project name
  3. version = release id
  4. GAV → repo path
  5. packaging + classifier optional

basics

~10 s

GAV stands for groupId, artifactId, version. Together they uniquely identify an artifact in a Maven repository. groupId is the owning org/namespace, artifactId is the project name, version is the release.

solid answer

~40 s

Maven coordinates uniquely address an artifact. The core triple is groupId (a reverse-DNS namespace for the owning org/team, e.g. org.springframework), artifactId (the specific module name, e.g. spring-core), and version (e.g. 5.3.30). Together GAV forms the address Maven uses to store, resolve, and download the artifact from a repository, mapping to a path like org/springframework/spring-core/5.3.30/. Two optional coordinates extend this: packaging (defaults to jar, decides the build lifecycle and output type) and classifier (a suffix to ship secondary artifacts like sources or javadoc alongside the main one). When you declare a dependency you give at least GAV; Maven uses it both to find your project's own output and to locate dependencies transitively.

code

xml · 5 lines
xml
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
  <version>3.14.0</version>
</dependency>

go deeper

for a junior

Recall that GAV = groupId, artifactId, version and that it uniquely identifies an artifact.

for a middle

Explain how GAV maps to the repository path and filename, plus the optional packaging/classifier coordinates.

for a senior

Discuss naming conventions, namespace ownership, and how GAV drives transitive resolution and conflict mediation.

for a principal

Govern org-wide groupId conventions, artifact naming standards, and how coordinate hygiene affects monorepo/multi-team artifact discoverability.

## What are Maven coordinates? Maven is a build tool that stores every built artifact (a JAR, WAR, etc.) in a **repository** — a structured directory tree (your local `~/.m2/repository`, plus remote ones like Maven Central). To find any artifact unambiguously, Maven gives each one an address called its **coordinates**, commonly abbreviated **GAV**. ## The three core coordinates - **groupId** — a namespace identifying the organization or team that owns the artifact. By convention it uses reverse-DNS, e.g. `org.apache.commons`. This avoids name clashes between different vendors. - **artifactId** — the name of the specific project/module within that group, e.g. `commons-lang3`. Must be unique within the group. - **version** — the release identity, e.g. `3.14.0`. Distinguishes builds of the same project over time. ## How coordinates map to a path Maven turns GAV into a repository path by replacing dots in groupId with slashes: ``` org/apache/commons/commons-lang3/3.14.0/commons-lang3-3.14.0.jar ``` The filename is `<artifactId>-<version>[-<classifier>].<extension>`. ## Two optional coordinates - **packaging** (`<packaging>`) — defaults to `jar`. It selects the build lifecycle bindings and the output type (jar, war, pom, etc.). - **classifier** (`<classifier>`) — an optional suffix that lets one GAV ship multiple artifacts, e.g. `sources`, `javadoc`, or a platform-specific build. ## In a pom.xml ```xml <project> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>billing-service</artifactId> <version>1.4.2</version> <packaging>jar</packaging> </project> ``` The same triple appears when you depend on something: ```xml <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.14.0</version> </dependency> ``` Maven uses GAV both to publish your project's output and to resolve every dependency (and their transitive dependencies) from repositories.

  • Why is reverse-DNS used for groupId?
    To guarantee global uniqueness across vendors — you own example.com, so com.example won't clash with anyone else's namespace.
  • What is the minimum needed to declare a dependency?
    groupId, artifactId, and a version (the version can be omitted if managed via dependencyManagement or a BOM).

GAV is like a postal address: groupId is the city/zone, artifactId is the street, version is the house number — together they point to exactly one place.

saying these in an interview costs you the question

  • Saying groupId and artifactId are interchangeable
  • Claiming version is optional in all cases (it's required unless managed)
  • Thinking coordinates are just labels and not the actual lookup key in the repository

context

open as a page

What does the <packaging> element do, and what are the common packaging types?

level: middleimportance: must knowfreq 70%

basics

~10 s

<packaging> tells Maven what kind of artifact to build and which lifecycle bindings to use. Common values: jar (default), war (web app), pom (aggregator/parent), and maven-plugin.

open as a page

Explain SNAPSHOT versus release versions in Maven, including deploy and timestamping semantics.

level: seniorimportance: must knowfreq 75%

basics

~20 s

A version ending in -SNAPSHOT is a mutable in-development version Maven re-checks for updates. A release version (no -SNAPSHOT) is immutable — once deployed it should never change. On deploy, snapshots get timestamped unique filenames; releases keep their plain version.

open as a page

What is <finalName> in the build section, and how does it relate to coordinates and the deployed artifact name?

level: middleimportance: should knowfreq 35%

basics

~10 s

<finalName> sets the base name of the output file produced in the target/ directory (e.g. target/app.war instead of app-1.0.0.war). It defaults to artifactId-version. It only renames the local build output, not the repository coordinates.

open as a page

What is a <classifier> in Maven and when would you use one?

level: seniorimportance: should knowfreq 45%

basics

~20 s

A classifier is an optional extra coordinate appended to the artifact filename, letting one GAV publish several distinct artifacts — for example -sources, -javadoc, or platform-specific builds — that share the same groupId, artifactId, and version.

open as a page

How does Maven parse and order version strings, and why does that matter for ranges and conflict resolution?

level: principalimportance: nice to knowfreq 25%

basics

~20 s

Maven splits versions into numeric and qualifier tokens separated by dots/dashes and compares them token by token. Known qualifiers like alpha < beta < milestone < rc < snapshot < (release) < sp order specially; unknown qualifiers sort alphabetically after the release.

open as a page