What is a Maven artifact?
What i开发者_如何学Pythons an artifact and why does Maven need it?
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.
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.
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.
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
.
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.
An artifact is a JAR or something that you store in a repository. Maven gets them out and builds your code.
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.
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.
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 :
https://connected2know.com/programming/what-is-maven/
https://connected2know.com/programming/maven-configuration/
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
精彩评论