Java 什么是 Maven 工件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2487485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is a Maven artifact?
提问by Maxim Veksler
What is an artifact and why does Maven need it?
什么是工件,为什么 Maven 需要它?
采纳答案by Stuart Sierra
An artifact is a file, usually a JAR, that gets deployed to a Maven repository.
工件是部署到 Maven 存储库的文件,通常是 JAR。
A Maven build produces one or more artifacts, such as a compiled JAR and a "sources" JAR.
Maven 构建会生成一个或多个工件,例如已编译的 JAR 和“源”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.
每个工件都有一个组 ID(通常是一个反向域名,如 com.example.foo)、一个工件 ID(只是一个名称)和一个版本字符串。这三者共同唯一地标识了神器。
A project's dependencies are specified as artifacts.
项目的依赖项被指定为工件。
回答by duffymo
An artifact is a JAR or something that you store in a repository. Maven gets them out and builds your code.
工件是 JAR 或您存储在存储库中的东西。Maven 将它们取出并构建您的代码。
回答by bmargulies
To maven, the build process is arranged as a set of artifacts. Artifacts include:
对于 maven,构建过程被安排为一组工件。文物包括:
- 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.
- 组成 Maven 本身的插件。
- 您的代码所依赖的依赖项。
- 您的构建产生的任何东西都可以被其他东西消耗。
Artifacts live in repositories.
工件存在于存储库中。
回答by Ken Liu
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.
在Maven的术语中,工件是所得的行家构建的输出,通常是jar
或war
或其他可执行文件。maven 中的工件由 groupId、artifactId 和 version 的坐标系统标识。Maven使用groupId
,artifactId
以及version
找出需要建立依赖关系(通常是其他jar文件),并运行代码。
回答by Marc-Christian Schulze
Maven organizes its build in projects.
Maven 在项目中组织其构建。
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.
一个artifact
in maven 是一个 maven 项目生成的资源。每个 maven 项目都可以有一个artifact
像jar, war, ear
等
。项目的配置文件"pom.xml"
描述了工件是如何构建的,单元测试是如何运行的,等等。通常,使用 maven 构建的软件项目由许多构建工件(例如 jars)的 maven 项目组成) 构成产品。
例如
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.
Maven 工件不仅限于 Java 资源。您可以生成所需的任何资源。例如文档、项目站点、zip 档案、本地库等。
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
.
每个 Maven 项目都有一个唯一的标识符,由[groupId, artifactId, version]
. 当一个 Maven 项目需要另一个项目的资源时,它会pom.xml
使用上述标识符配置一个依赖项。Maven 然后在触发构建时自动解析依赖项。然后,所需项目的工件从本地repository
(用户主目录中的一个简单目录)或从您指定的其他(远程)存储库加载pom.xml
。
回答by Laird Nelson
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.
有 Maven 工件、存储库管理器工件,然后是 Maven Artifact
。
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.
Maven 工件正如其他评论者/响应者所说:它是通过构建 Maven 项目而吐出的东西。那可能是一个.jar
文件,或者一个.war
文件,或者一个.zip
文件,或者一个.dll
,或者你有什么。
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...).
存储库管理器工件是由存储库管理器管理的东西。存储库管理器基本上是一种用于软件可执行文件和库的高性能命名服务。存储库管理器不关心它的工件来自哪里(也许它们来自 Maven 构建,或本地文件,或 Ant 构建,或手工编译......)。
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.
MavenArtifact
是一个 Java 类,它表示由存储库管理器取消引用到存储库管理器工件的“名称”类型。当在这个意义上使用的,Artifact
就是这样的部件作为由一个荣耀的名字groupId
,artifactId
,version
,scope
,classifier
等。
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 theyask the repository manager for it.
- 您的 Maven 项目
Artifact
通过其<dependency>
元素可能依赖于多个s 。 - Maven 与存储库管理器交互,
Artifact
通过指示存储库管理器向其发送一些与内部Artifact
s相对应的存储库管理器工件,将这些s解析为文件。 - 最后,在解析之后,Maven 会构建您的项目并生成一个 Maven 工件。您可以选择“把它变成”由仓库管理器神器,反过来,用你喜欢的任何工具,它有足够的协调信息,其他人可以找到它,当发送到存储库管理,他们要求仓库管理它。
Hope that helps.
希望有帮助。
回答by Venky Vungarala
usually we talking Maven Terminology about Group Id , Artifact Id and Snapshot Version
通常我们谈论 Maven 术语关于 Group Id ,Artifact Id 和 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.
Group Id:项目所属组的标识 Artifact Id:项目标识 Snapshot version:项目使用的版本。
Artifact is nothing but some resulting file like Jar, War, Ear....
Artifact 只不过是一些结果文件,如 Jar、War、Ear....
simply says Artifacts are nothing but packages.
简单地说,Artifacts 只不过是包。
回答by VdeX
Q. What is Artifact in maven?
ANS: ARTIFACT is a JAR,(WAR or EAR), but it could be also something else. Each artifact has,
问:maven 中的 Artifact 是什么?
ANS:ARTIFACT 是一个 JAR,(WAR 或 EAR),但它也可能是其他东西。每个神器都有,
- a group ID (like com.your.package),
- an artifact ID (just a name), and
- a version string.
The three together uniquely identify the artifact.
- 组 ID(如 com.your.package),
- 一个工件 ID(只是一个名称),以及
- 一个版本字符串。
这三者共同唯一地标识了神器。
Q.Why does Maven need them?
Ans: Maven is used to make them available for our applications.
Q. 为什么 Maven 需要它们?
Ans:Maven 用于使它们可用于我们的应用程序。