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
级别,(例如,如果您的groupId
isorg.foo.examples
和 your artifactId
is hello-world
,则路径将为org/foo/examples/hello-world/maven-metadata.xml
)。这用于管理基本版本或发布版本。
- 版本级别:这是在
groupId
//级别, artifactId
(version
例如,如果您的groupId
isorg.foo.examples
和 your artifactId
ishello-world
和 version is 1.0-SNAPSHOT
,则路径将为org/foo/examples/hello-world/1.0-SNAPSHOT/maven-metadata.xml
)。这用于管理带时间戳的快照。
- 插件组级别:这是插件的
groupId
级别,用于管理同一插件组下的不同插件。
有关 Maven 元数据如何工作的非常详细的说明,请查看我整理的这篇文章。