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