sofs1
sofs1

Reputation: 4176

What is the difference between artifactId and groupId in pom.xml?

How would you explain it to a newbie web developer or programmer with some real world organization example (like say facebook company or Google company)?

Upvotes: 53

Views: 103253

Answers (5)

Uddhav P. Gautam
Uddhav P. Gautam

Reputation: 7636

In POM, or anywhere, an artifact has three things

  1. List item
  2. group id
  3. version

group id uniquely tells where it belongs, artifact id tells what it is and version tells what exact version of the artifact.

For example, androidx.activity:activity-compose:1.7.1

Syntax: groupid:atrifactid:version

This means for androidx.activity:activity-compose:1.7.1, androidx.activity is a group id, activity-compose is an artifact id, and 1.7.1 is version of artifact.

You can check this in google repo (url: https://maven.google.com/web/index.html?q=activity-compose#androidx.activity:activity-compose:1.7.1) screenshot below,

enter image description here

The link of actual artifact: https://dl.google.com/android/maven2/androidx/activity/activity-compose/1.7.1/activity-compose-1.7.1.aar

Upvotes: 2

  • groupId uniquely identifies your project across all projects.
  • artifactId is the name of the jar without version.

Upvotes: 2

Badar Ali
Badar Ali

Reputation: 131

In case of newbie understanding. This Link describes the best understanding of project identifiers. If I narrow down to main topic then here is the point:

Maven uses a set of identifiers, also called coordinates, to uniquely identify a project and specify how the project artifact should be packaged:

  • groupId – a unique base name of the company or group that created the project
  • artifactId – a unique name of the project

If you want to understand how these identifiers have impact on POM you can visit

  1. Project Inheritance
  2. Project Aggregation

Upvotes: 10

Pramod Kumar
Pramod Kumar

Reputation: 29

The main difference between groupId and artifactId in Maven is that the groupId specifies the id of the project group while the artifactId specifies the id of the project.

It is required to use third party libraries when developing a project. The programmer can download and add these third-party libraries to the project, but it is difficult to update them later. Maven provides a solution to this issue. It helps to include all the dependencies required for the project. Moreover, the programmer can specify the required dependencies in the POM.XML file. It has the configuration information to build the project. Furthermore, this file consists of several XML elements, and two of them are groupId and artifactId. example groupId : com.test.java (similar to package name) artifactId : javaproject(project or module name)

Upvotes: 0

Jameson
Jameson

Reputation: 6679

From maven.apache.org, Naming Conventions:

artifactId is the name of the jar without version. If you created it then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar you have to take the name of the jar as it's distributed. eg. maven, commons-math

groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. Look at More information about package names. eg. org.apache.maven, org.apache.commons

Upvotes: 44

Related Questions