<!--定义snapshots库和releases库的nexus地址-->
<distributionManagement>
<repository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/33566-release-BheiIK/</url>
</repository>
<!-- <repository>-->
<!-- <id>2138699-release-xv0wqi</id>-->
<!-- <url>https://packages.aliyun.com/maven/repository/2138699-release-xv0wqi/</url>-->
<!-- </repository>-->
<snapshotRepository>
<id>rdc-snapshots</id><!--对应setting.xml里面的server节点下的serverid-->
<url>https://repo.rdc.aliyun.com/repository/33566-snapshot-EE05gc/</url>
</snapshotRepository>
<!-- <snapshotRepository>-->
<!-- <id>2138699-snapshot-yeXAwF</id>-->
<!-- <url>https://packages.aliyun.com/maven/repository/2138699-snapshot-yeXAwF/</url>-->
<!-- </snapshotRepository>-->
</distributionManagement>
我使用 swagger 在我的项目中生成 Web 服务客户端。生成的代码生成一个可以用作 Maven 库的库。我已经成功地将发布版本部署到我的私有 (private) sonatype-nexus 中。
我想知道 altDeploymentRepository
和 altReleaseDeploymentRepository
有什么区别?如果设置了这两个参数,mvn deploy
如何选择要使用的存储库?
作为 apache-maven deploy documentation 说:
altDeploymentRepository: Specifies an alternative repository to which the project artifacts should be deployed ( other than those specified in ). Format: id::layout::url
altReleaseDeploymentRepository: The alternative repository to use when the project has a final version.
altSnapshotDeploymentRepository: The alternative repository to use when the project has a snapshot version.
具体是做什么的
when the project has a final version.
是什么意思?
最佳答案
当 altReleaseDeploymentRepository 被指定,当项目有发布 (或 “最终”) 版本时总是使用它,即不是快照版本。当 altSnapshotDeploymentRepository 被指定,它总是在项目有快照版本时使用。 altDeploymentRepository 当没有指定或使用上述存储库时,是默认的备用部署存储库。
所以换句话说,如果你有一个发布版本,那么:
altReleaseDeploymentRepository
将在指定时使用;- 否则
altDeploymentRepository
将在指定时使用; - 否则发布在 <distributionManagement><repository> 中声明的远程仓库如果指定,将使用 POM 元素;
- 否则插件会出错,因为它没有找到任何要部署到的远程存储库。
同样,如果你有一个快照版本,那么:
altSnapshotDeploymentRepository
将在指定时使用;- 否则
altDeploymentRepository
将在指定时使用; - 否则在 <distributionManagement><snapshotRepository> 中声明的快照远程存储库如果指定,将使用 POM 元素;
- 否则发布在 <distributionManagement><repository> 中声明的远程仓库如果指定,将使用 POM 元素;
- 否则插件会出错,因为它没有找到任何要部署到的远程存储库。