2

maven部署工件有什么顺序吗?据我所知,我可以说它上传了所有工件,最后它更新了 maven-medata.xml 文件

http://localhost:8000/mavenrepository/test1/com/mypackage/mavenproject1/1.0-SNAPSHOT/maven-metadata.xml http://localhost:8000/mavenrepository/test1/com/mypackage/mavenproject1/maven-metadata.xml

现在可以保证maven在上传其他工件后总是最后上传这2个文件吗?

4

1 回答 1

4

Maven 总是以相同的顺序部署工件文件。它通常看起来像这样:

[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ hello-world ---
Downloading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/hello-world-1.0-20160430.031713-1.jar
Uploaded: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/hello-world-1.0-20160430.031713-1.jar (3 KB at 11.5 KB/sec)
Uploading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/hello-world-1.0-20160430.031713-1.pom
Uploaded: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/hello-world-1.0-20160430.031713-1.pom (2 KB at 41.6 KB/sec)
Downloading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/maven-metadata.xml
Uploading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/1.0-SNAPSHOT/maven-metadata.xml (798 B at 21.1 KB/sec)
Uploading: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/maven-metadata.xml
Uploaded: http://localhost:48080/storages/storage0/snapshots/org/foo/examples/hello-world/maven-metadata.xml (312 B at 8.7 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

如您所见,它所做的第一件事是尝试maven-metadata.xml在工件级别解析文件,以确定该工件是否有其他版本以及是否生成全新maven-metadata.xml文件或更新现有文件,(如果有这样的),以及它正在部署的新版本。该maven-metadata.xml文件始终在部署结束时生成或更新。

maven-metadata.xml文件可以位于三个级别:

  • 工件级别:在groupId/artifactId级别,(例如,如果您的groupIdisorg.foo.examples和 your artifactIdis hello-world,则路径将为org/foo/examples/hello-world/maven-metadata.xml)。这用于管理基本版本或发布版本。
  • 版本级别:这是在groupId//级别, artifactIdversion例如,如果您的groupIdisorg.foo.examples和 your artifactIdishello-world和 version is 1.0-SNAPSHOT,则路径将为org/foo/examples/hello-world/1.0-SNAPSHOT/maven-metadata.xml)。这用于管理带时间戳的快照。
  • 插件组级别:这是插件的groupId级别,用于管理同一插件组下的不同插件。

有关 Maven 元数据如何工作的非常详细的说明,请查看我整理的这篇文章。

于 2017-05-12T10:42:05.650 回答