Maven的pom.xml文件结构之环境配置distributionManagement

Maven项目的POM中,环境配置<distributionManagement>负责管理构件的发布。

当然,完整的配置,还需要在settings.xml中配置构件库所在的服务器server相关的参数。

1.<distributionManagement>的基本配置

  <distributionManagement>
    ...
    <downloadUrl>http://cat.myserver.org/my-project</downloadUrl>
    <status>deployed</status>
  </distributionManagement>

说明:

  • downloadUrl,一个URL,其他Maven项目可以通过该URL下载并引用当前Maven项目的构件。注意区别本文下面的<repository>中的URL,<repository>中的URL给出了当前Maven项目的构件的发布URL。
  • status,当前Maven项目的状态,可用的状态如下所示。注意,该值是由Maven自动设置,永远不要人工设置。
    • none,未指明状态,默认值
    • converted,该Maven项目的构件已经被转换为兼容Maven 2
    • partner,该Maven项目的构件保持与另一个库的Maven版本一致
    • deployed,该Maven项目的构件是通过Maven 2或Maven 3发布的,最常用的值
    • verified,该Maven项目的构件已经被验证过

2.<distributionManagement>的<repository>配置

给出Maven部署当前项目的构件到远程库时,关于远程库的配置。示例如下:

  <distributionManagement>
    <repository>
      <uniqueVersion>false</uniqueVersion>
      <id>corp1</id>
      <name>Corporate Repository</name>
      <url>scp://repo/maven2</url>
      <layout>default</layout>
    </repository>
    <snapshotRepository>
      <uniqueVersion>true</uniqueVersion>
      <id>propSnap</id>
      <name>Propellors Snapshots</name>
      <url>sftp://propellers.net/maven</url>
      <layout>legacy</layout>
    </snapshotRepository>
    ...
  </distributionManagement>

具体配置参数,参考前文。

3. <distributionManagement>的<site>配置

除了部署当前Maven项目的构件,还可以部署当前Maven项目的网站和文档。示例如下:

  <distributionManagement>
    ...
    <site>
      <id>mojo.website</id>
      <name>Mojo Website</name>
      <url>scp://beaver.codehaus.org/home/projects/mojo/public_html/</url>
    </site>
    ...
  </distributionManagement>

这里的配置参数与<repository>中的对应配置参数一致。

4. <distributionManagement>的<relocation>配置

随着一个Maven项目的发展壮大,该Maven项目的构件可能需要重新发布到新的库。<relocation>可以将当前Maven项目以新的构件的形式发布到另一个库。示例如下:

  <distributionManagement>
    ...
    <relocation>
      <groupId>org.apache</groupId>
      <artifactId>my-project</artifactId>
      <version>1.0</version>
      <message>We have moved the Project under Apache</message>
    </relocation>
    ...
  </distributionManagement>

 

  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值