简体   繁体   English

如何从外部文件获取scm连接网址到pom.xml中?

[英]How to get the scm connnectionurl from an external file into the pom.xml?

I want to get the connectionUrl and other properties such as modules to checkout the repositories from an external file(not necessarily xml file) into the pom file. 我想获取connectionUrl和其他属性(例如modules以将存储库从外部文件(不一定是xml文件)检出到pom文件中。

My pom file looks like: 我的pom文件如下所示:

<project>...
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-scm-plugin</artifactId>
       <version>1.5</version>
       <configuration>
         <username>${svn.username}</username>
         <password>${svn.pass}</password>`enter code here`
         <checkoutDirectory>${path}</checkoutDirectory>
         <skipCheckoutIfExists/>
       </configuration>
       <executions>
         <execution>
           <id>checkout_a</id>
           <configuration>
             <connectionUrl>I want to get the url and other properties from a xml file</connectionUrl>
             <checkoutDirectory>${path}</checkoutDirectory>
           </configuration>
           <phase>process-resources</phase>
             <goals>
               <goal>checkout</goal>
             </goals>
        </execution>
      </executions>
  </plugin>     
</plugins>
</build>
</project>

Use the properties plugin to read pom properties from a properties file . 使用属性插件从属性文件读取pom属性 If not a properties file, then you'll probably need to use GMaven , write some groovy code to parse the file, and then update the pom properties yourself. 如果不是属性文件,则可能需要使用GMaven ,编写一些常规代码来解析该文件,然后自己更新pom属性。

The simplest approach would be to declare the svn url as a property in your pom.xml, as illustrated in this (french) article ( translated here ). 最简单的方法是将svn url声明为pom.xml中的一个属性,如这篇(法语)文章在此处翻译 )所示。

<connection>scm:svn:http://my.svn.server/trunk</connection> 

However, like this thread illustrates , you cannot get the "current" repo (through svn info ). 但是,如该线程所示 ,您无法(通过svn info )获取“当前”存储库。

And you can see here for an scm ClearCase URL : 您可以在此处看到scm ClearCase URL

scm:clearcase<delimiter>[viewName]<delimiter>[loadCommand]<delimiter>[VOBName]<delimiter>[streamName]<delimiter>/main/fooBar/LATEST

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM