What is an artifact and why does Maven need it?
-
5More about Maven concepts here: http://tshikatshikaaa.blogspot.nl/2012/05/introduction-to-maven-concepts-crash.html – Jérôme Verstrynge Jul 27 '12 at 14:50
-
1btw You can see the official Apache Maven glossary for the definition of an [*Artifact*](http://maven.apache.org/glossary.html#Artifact) – informatik01 Jul 05 '13 at 23:24
-
1None of these answers is complete. You can see this just by [browsing a Maven repository](http://search.maven.org/#browse|842264825). An artifact is apparently a *directory* satisfying some constraints, e.g. it must contain a file called `maven-metadata.xml` and a file called `
- – jameshfisher Oct 29 '14 at 11:16.pom`. Both of those files have some undocumented schema and semantics.
10 Answers
An artifact is a file, usually a JAR, that gets deployed to a Maven repository.
A Maven build produces one or more artifacts, such as a compiled JAR and a "sources" JAR.
Each artifact has a group ID (usually a reversed domain name, like com.example.foo), an artifact ID (just a name), and a version string. The three together uniquely identify the artifact.
A project's dependencies are specified as artifacts.

- 10,837
- 2
- 29
- 35
-
10Is an artifact basically a JAR file ? So, the joda time jar file can be called a joda artifact, hibernate jar can be called hibernate artifact etc ? – david blaine Apr 17 '13 at 00:53
-
59Think of what an artifact really is. The Egyptians created wonderful artifacts such as pottery. But, if you were holding an Egyptian bowl in your hand, you wouldn't refer to it as an "artifact" unless you were discussing the fact that it IS an artifact (fact). You would refer to it as a bowl. They ate out of the bowl. They didn't eat out of the artifact. – cbmeeks Apr 10 '14 at 17:22
-
10I think what @cbmeeks is getting at is that "artifact" is not a name for a "thing", it is a _role_ in the build process. Anything can be classified as an "artifact" if Maven produces it and it is given special Maven _coordinates_ to identify it. – Garret Wilson Mar 15 '19 at 15:53
-
If I have something called "com.example:mylibrary:1.0.0" (groupId:artifactId:version), that consists of a jar, a pom, and a source jar, which of the following is an artifact: 1. each file (pom, jar, source jar) is a separate artifact; 2. the set of files that share the same (groupId:artifactId:version) make up a single artifact; 3. something else? – Laurence Gonsalves Mar 29 '19 at 04:06
-
You don't explain how to get the groupid and artifactid given the name of the class. Downvote – Philip Rego Apr 02 '19 at 20:10
-
1There isn't necessarily any relationship between groupId/artifactId and class names. Often, the groupId/artifactId will match the Java package. For example, a class named `com.example.myproject.MyClass` might be found in groupId `com.example` and artifactId `myproject`, but this is only a convention. Maven itself does not enforce this convention. Some repositories, [such as Maven Central](https://central.sonatype.org/pages/choosing-your-coordinates.html), enforce it for new projects. – Stuart Sierra Dec 02 '19 at 01:42
In general software terms, an "artifact" is something produced by the software development process, whether it be software related documentation or an executable file.
In Maven terminology, the artifact is the resulting output of the maven build, generally a jar
or war
or other executable file. Artifacts in maven are identified by a coordinate system of groupId, artifactId, and version. Maven uses the groupId
, artifactId
, and version
to identify dependencies (usually other jar files) needed to build and run your code.

- 22,503
- 19
- 75
- 98
-
My book says "the core artifact of this online application will be a Java class named User, which will"... Is this the same as the artifact you mentioned ? – david blaine Apr 17 '13 at 00:57
-
@davidblaine - not exactly, that sentence uses the word a more general sense. – Ken Liu Apr 17 '13 at 03:35
I know this is an ancient thread but I wanted to add a few nuances.
There are Maven artifacts, repository manager artifacts and then there are Maven Artifact
s.
A Maven artifact is just as other commenters/responders say: it is a thing that is spat out by building a Maven project. That could be a .jar
file, or a .war
file, or a .zip
file, or a .dll
, or what have you.
A repository manager artifact is a thing that is, well, managed by a repository manager. A repository manager is basically a highly performant naming service for software executables and libraries. A repository manager doesn't care where its artifacts come from (maybe they came from a Maven build, or a local file, or an Ant build, or a by-hand compilation...).
A Maven Artifact
is a Java class that represents the kind of "name" that gets dereferenced by a repository manager into a repository manager artifact. When used in this sense, an Artifact
is just a glorified name made up of such parts as groupId
, artifactId
, version
, scope
, classifier
and so on.
To put it all together:
- Your Maven project probably depends on several
Artifact
s by way of its<dependency>
elements. - Maven interacts with a repository manager to resolve those
Artifact
s into files by instructing the repository manager to send it some repository manager artifacts that correspond to the internalArtifact
s. - Finally, after resolution, Maven builds your project and produces a Maven artifact. You may choose to "turn this into" a repository manager artifact by, in turn, using whatever tool you like, sending it to the repository manager with enough coordinating information that other people can find it when they ask the repository manager for it.
Hope that helps.

- 31,231
- 29
- 115
- 197

- 15,321
- 19
- 73
- 127
-
1+1 for new info on old thread thanks! Fix typo "repoository" though at times poo might be the right word haha ... everyone is saying the "artifact" is the actual jar, might be helpful to update your answer to point out that when using, for example, `mvn install`, people are trying to figure out what to put in that entry. So the full name of the jar is what to enter for `-DartifactId=YOUR_ARTIFACT_ID`, is that right? The full jar file name with version and .jar? Seems to be what you're saying but would help some to be really explicit. Other answers get close to this but I thought yours best. – JimLohse Oct 26 '16 at 14:25
Maven organizes its build in projects.
An artifact
in maven is a resource generated by a maven project. Each maven project can have exactly one artifact
like a jar, war, ear
, etc.
The project's configuration file "pom.xml"
describes how the artifact is build, how unit tests are run, etc.
Commonly a software project build with maven consists of many maven-projects that build artifacts (e.g. jars) that constitute the product.
E.g.
Root-Project // produces no artifact, simply triggers the build of the other projects
App-Project // The application, that uses the libraries
Lib1-Project // A project that creates a library (jar)
Lib2-Project // Another library
Doc-Project // A project that generates the user documentation from some resources
Maven artifacts are not limited to java resources. You can generate whatever resource you need. E.g. documentation, project-site, zip-archives, native-libraries, etc.
Each maven project has a unique identifier consiting of [groupId, artifactId, version]
. When a maven project requires resources of another project a dependency is configured in it's pom.xml
using the above-mentioned identifier. Maven then automatically resolves the dependencies when a build is triggered. The artifacts of the required projects are then loaded either from the local repository
, which is a simple directory in your user's home, or from other (remote) repositories specified in you pom.xml
.

- 479,566
- 201
- 878
- 984

- 3,154
- 3
- 35
- 45
Q. What is Artifact in maven?
ANS: ARTIFACT is a JAR,(WAR or EAR), but it could be also something else. Each artifact has,
- a group ID (like com.your.package),
- an artifact ID (just a name), and
- a version string.
The three together uniquely identify the artifact.
Q.Why does Maven need them?
Ans: Maven is used to make them available for our applications.
-
Nice answer, as I commented on [other answer](http://stackoverflow.com/a/20984861/3255525), make it explicit what we are supposed to type into `-DartifactId=YOUR_ARTIFACT_ID` when running mvn install, just a suggestion :) – JimLohse Oct 26 '16 at 14:27
-
An artifact is a JAR or something that you store in a repository. Maven gets them out and builds your code.

- 305,152
- 44
- 369
- 561
To maven, the build process is arranged as a set of artifacts. Artifacts include:
- The plugins that make up Maven itself.
- Dependencies that your code depends on.
- Anything that your build produces that can, in turn be consumed by something else.
Artifacts live in repositories.

- 97,814
- 39
- 186
- 310
usually we talking Maven Terminology about Group Id , Artifact Id and Snapshot Version
Group Id:identity of the group of the project Artifact Id:identity of the project Snapshot version:the version used by the project.
Artifact is nothing but some resulting file like Jar, War, Ear....
simply says Artifacts are nothing but packages.

- 1,175
- 10
- 6
Usually, when you create a Java project you want to use functionalities made in another Java projects. For example, if your project wants to send one email you dont need to create all the necessary code for doing that. You can bring a java library that does the most part of the work. Maven is a building tool that will help you in several tasks. One of those tasks is to bring these external dependencies or artifacts to your project in an automatic way ( only with some configuration in a XML file ). Of course Maven has more details but, for your question this is enough. And, of course too, Maven can build your project as an artifact (usually a jar file ) that can be used or imported in other projects.
This website has several articles talking about Maven :

- 129
- 1
- 5
An artifact is an element that a project can either use or produce. In Maven terminology, an artifact is an output generated after a Maven project build. It can be, for example, a jar, war, or any other executable file.
Also, Maven artifacts include five key elements, groupId, artifactId, version, packaging, and classifier. Those are the elements we use to identify the artifact and are known as Maven coordinates.
read it from here

- 459
- 6
- 13