作者:永川青峰_915 | 来源:互联网 | 2024-09-30 10:32
本文翻译自:What is a Maven artifact?
什么是神器?为什么Maven需要它?
#1楼
参考:https://stackoom.com/question/AR6j/什么是Maven神器
#2楼
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. Maven工件正如其他评论者/响应者所说的那样:通过构建Maven项目来实现这一点。 That could be a .jar
file, or a .war
file, or a .zip
file, or a .dll
, or what have you. 这可能是.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. Maven Artifact
是一个Java类,它表示由存储库管理器取消引用到存储库管理器工件中的“名称”类型。 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. 在这个意义上使用时, Artifact
只是一个美化的名称,由groupId
, artifactId
, version
, scope
, classifier
等部分组成。
To put it all together: 把它们放在一起:
- Your Maven project probably depends on several
Artifact
s by way of its
elements. 您的Maven项目可能通过其
元素依赖于几个Artifact
。 - 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 internal Artifact
s. Maven与存储库管理器交互,通过指示存储库管理器向其发送一些与内部Artifact
对应的存储库管理器工件,将这些Artifact
解析为文件。 - Finally, after resolution, Maven builds your project and produces a Maven artifact. 最后,在解决之后,Maven构建您的项目并生成Maven工件。 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. 希望有所帮助。
#3楼
An artifact is a JAR or something that you store in a repository. 工件是JAR或存储在存储库中的东西。 Maven gets them out and builds your code. Maven将它们取出并构建您的代码。
#4楼
To maven, the build process is arranged as a set of artifacts. 对于maven,构建过程被安排为一组工件。 Artifacts include: 文物包括:
- The plugins that make up Maven itself. 构成Maven的插件本身。
- Dependencies that your code depends on. 代码所依赖的依赖关系。
- Anything that your build produces that can, in turn be consumed by something else. 构建产生的任何东西都可以被其他东西消耗掉。
Artifacts live in repositories. 工件存放在存储库中。
#5楼
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. 在Maven术语中,工件是maven构建的结果输出,通常是jar
或war
或其他可执行文件。 Artifacts in maven are identified by a coordinate system of groupId, artifactId, and version. maven中的工件由groupId,artifactId和version的坐标系标识。 Maven uses the groupId
, artifactId
, and version
to identify dependencies (usually other jar files) needed to build and run your code. Maven使用groupId
, artifactId
和version
来识别构建和运行代码所需的依赖项(通常是其他jar文件)。
#6楼
An artifact is a file, usually a JAR, that gets deployed to a Maven repository. 工件是一个文件,通常是JAR,可以部署到Maven存储库。
A Maven build produces one or more artifacts, such as a compiled JAR and a "sources" JAR. Maven构建会生成一个或多个工件,例如已编译的JAR和“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. 每个工件都有一个组ID(通常是反向域名,如com.example.foo),工件ID(只是一个名称)和一个版本字符串。 The three together uniquely identify the artifact. 三者一起唯一地识别工件。
A project's dependencies are specified as artifacts. 项目的依赖项被指定为工件。