什么是工件,Maven为什么需要它?
当前回答
对于maven,构建过程被安排为一组工件。产品包括:
组成Maven本身的插件。 代码所依赖的依赖项。 构建生成的任何东西都可能被其他东西消耗。
工件存在于存储库中。
其他回答
在一般的软件术语中,“工件”是由软件开发过程产生的东西,无论是与软件相关的文档还是可执行文件。
在Maven术语中,工件是Maven构建的结果输出,通常是jar或war或其他可执行文件。maven中的工件由groupId、artifactId和version组成的坐标系统标识。Maven使用groupId、artifactId和version来标识构建和运行代码所需的依赖项(通常是其他jar文件)。
工件是部署到Maven存储库的文件,通常是JAR。
Maven构建生成一个或多个工件,例如编译后的JAR和“源”JAR。
每个工件都有一个组ID(通常是反向域名,如com.example.foo)、一个工件ID(只是一个名称)和一个版本字符串。三者合在一起唯一地识别了这个神器。
项目的依赖项被指定为工件。
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.
这个网站上有几篇关于Maven的文章:
https://connected2know.com/programming/what-is-maven/
https://connected2know.com/programming/maven-configuration/
工件是项目可以使用或生成的元素。在Maven术语中,工件是Maven项目构建后生成的输出。例如,它可以是jar、war或任何其他可执行文件。
此外,Maven工件包括五个关键元素,groupId、artifactId、版本、打包和分类器。这些是我们用来识别工件的元素,被称为Maven坐标。
从这里开始阅读
Maven在项目中组织其构建。
maven中的工件是由maven项目生成的资源。每个maven项目都可以有一个工件,比如罐子、战争、耳朵等。 项目的配置文件“pom.xml”描述了如何构建工件,如何运行单元测试等等。 通常,使用maven构建的软件项目由许多maven项目组成,这些maven项目构建了构成产品的工件(例如jar)。 如。
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工件并不局限于java资源。你可以生成任何你需要的资源。例如文档、项目站点、zip-archives、本地库等。
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.
推荐文章
- Intellij IDEA Java类在保存时不能自动编译
- 何时使用Mockito.verify()?
- 在maven中安装mvn到底做什么
- 不可变与不可修改的集合
- 如何在JSON中使用杰克逊更改字段名
- GSON -日期格式
- 如何从线程捕获异常
- 无法解析主机"<URL here>"没有与主机名关联的地址
- 如何在Java中打印二叉树图?
- String.format()在Java中格式化双重格式
- com.jcraft.jsch.JSchException: UnknownHostKey
- Java中的操作符重载
- 如何加速gwt编译器?
- 在Hibernate中重新连接分离对象的正确方法是什么?
- 应该……接住环内还是环外?