Maven 中不同配置文件的不同 SCM [英] Different SCM for different profiles in Maven

查看:65
本文介绍了Maven 中不同配置文件的不同 SCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my project we have to use maben-build-number plugin to construct the final name of the jar, for that purpose we use the revision of the SCN, so we need SCM

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

But we have two SVN on controlled environment without direct access and on our local test environment, so for our pouproses we have to use:

<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>

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

Is it possible to configure this in the different profiles. I tried

<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 时,没有任何反应?

But when I use the profile -Plocal, nothing happens?

推荐答案

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

I solved this problem by creating a property for the SCM connection details I need to change for different profiles. Here is a summary of what I did.

定义属性和属性块的默认值.

Defined the property and it's default value the properties block.

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

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

Set the scm block properties to use the global properties.

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

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

Created a profile which changes the global property as required.

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

据我所知,通过对架构的快速扫描,scm 标记只能在 POM 的顶层使用,并且在 profile 标签

As far as I know and from a quick scan of the schema the scm tag can only be used at the top level in the POM and is not valid inside the profile tag

这篇关于Maven 中不同配置文件的不同 SCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆