如何更改部署到不同环境的存储库ID?

时间:2019-09-30 14:57:10

标签: maven

现在,我在应用程序的POM中拥有此功能,可以将其部署到内部Maven存储库中进行开发:

  <distributionManagement>
      <repository>
          <id>development-repo</id>
          <name>development-repo</name>
          <url>https://artifactory/development-repo</url>
      </repository>
      <snapshotRepository>
          <id>development-repo</id>
          <name>development-repo</name>
          <url>https://artifactory/development-repo</url>
      </snapshotRepository>
  </distributionManagement>

但是我也有一个产品仓库。我想做的是在pom中包括这两个内容,默认为dev并有一种从命令行切换为prod的方法-这可能吗?

例如,我的poms看起来像这样:

  <!-- default to these repos so running mvn deploy will just deploy to them -->
  <repository>
      <id>development-repo</id>
      <name>development-repo</name>
      <url>https://artifactory/development-repo</url>
  </repository>
  <snapshotRepository>
      <id>development-repo</id>
      <name>development-repo</name>
      <url>https://artifactory/development-repo</url>
  </snapshotRepository>

  <!-- Have some way of passing switch to maven to deploy to prod repos (used by CI\CD server -->
  <repository>
      <id>production-repo</id>
      <name>production-repo</name>
      <url>https://artifactory/development-repo</url>
  </repository>
  <snapshotRepository>
      <id>production-repo</id>
      <name>production-repo</name>
      <url>https://artifactory/production-repo</url>
  </snapshotRepository>

我知道maven具有配置文件的概念,但这似乎有点沉重?实际上,我什至在考虑只让CI \ CD服务器对pom进行文本转换,以将production-repo替换为production-repo,但是如果可能的话,我想这样做。

0 个答案:

没有答案