Maven 中不同配置文件的不同 SCM

2024-05-17

在我的项目中,我们必须使用 maben-build-number 插件来构造 jar 的最终名称,为此我们使用 SCN 的修订版,因此我们需要 SCM

但是我们在无法直接访问的受控环境和本地测试环境上有两个 SVN,因此对于我们的 pouproses,我们必须使用:

<scm>
    <connection>scm:svn:http://dev.com/svn_repo/trunk</connection>
    <developerConnection>scm:svn:https://dev.com/svn_repo/trunk</developerConnection>
    <url>http://dev.com/view.cvs</url>
</scm>

但对于客户端环境:

      <scm>
        <connection>scm:svn:http://client.com/svn_repo/trunk</connection>
        <developerConnection>scm:svn:https://client.com/svn_repo/trunk</developerConnection>
        <url>http://client.com/view.cvs</url>
      </scm>

是否可以在不同的配置文件中进行配置。我试过

<profiles>
  <profile>
    <id>local</id>
    <scm>
        <connection>scm:svn:http://client.com/svn_repo/trunk</connection>
        <developerConnection>scm:svn:https://client.com/svn_repo/trunk</developerConnection>
        <url>http://client.com/view.cvs</url>
      </scm>
  </profile>
  <profile>
    <id>remote</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <scm>
        <connection>scm:svn:http://client.com/svn_repo/trunk</connection>
        <developerConnection>scm:svn:https://client.com/svn_repo/trunk</developerConnection>
        <url>http://client.com/view.cvs</url>
      </scm>
  </profile>
</profiles>

但是当我使用配置文件 -Plocal 时,没有任何反应?


我通过为需要针对不同配置文件更改的 SCM 连接详细信息创建属性来解决此问题。这是我所做的总结。

定义属性及其默认值的属性块。

<properties>
    <developerConnectionUrl><!-- developerConnection url here --></developerConnectionUrl>
</properties>

设置 scm 块属性以使用全局属性。

<scm>
    <developerConnection>${developerConnectionUrl}</developerConnection>
</scm>

创建了一个根据需要更改全局属性的配置文件。

<profiles>
    <profile>
        <id>local</id>
        <properties>
            <developerConnectionUrl><!-- developerConnectionUrl url for profile --></developerConnectionUrl>
        </properties>
    </profile>
</profiles>

据我所知,通过对架构的快速扫描scm标签只能在POM的顶层使用,在POM内部无效profile tag

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Maven 中不同配置文件的不同 SCM 的相关文章

随机推荐