5

我有一个依赖于多个模块的 Web 应用程序。所以要构建它,我有一个主 pom.xml 文件。我想要这个 pom 文件做的是检出所有模块。下面是我的 pom 文件。

        <executions>
        <execution>
                    <id>check-out-project1</id>
                    <phase>generate-sources</phase>
                    <goals>
                    <goal>checkout</goal>
                    </goals>
                    <configuration>    
                    <checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
                    <connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
                    <!--<developerConnection>scm:svn:svn://svnserver/svn/module1/trunk</developerConnection>!-->
                    <username>username</username>                             
                    <password>password</password>             
                    </configuration>
         </execution>

          <execution>
                    <id>check-out-project2</id>
                    <phase>generate-sources</phase>
                    <goals>
                    <goal>checkout</goal>
                    </goals>
                    <configuration>    
                    <checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
                    <connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
                          <username>username</username>                             
                          <password>password</password>             
                    </configuration>
            </execution>
        </executions>

我已经尝试过mvn scm:checkoutmvn scm:checkout -check-out-project1但它给了我错误: 无法运行结帐命令:无法加载 scm 提供程序。您需要定义一个 connectionUrl 参数。

我不明白为什么会发生这种情况,因为我已经在 pom 文件中定义了 connectionUrl 参数,我想要得到的想法点是将 pom 文件配置为能够同时签出多个项目。请让我知道我在这里做错了什么,在此先感谢。

4

2 回答 2

3

我发现,如果将每个结帐都放在自己<execution> ... </execution>的位置,并且个人<configuration> ... </configuration>为他们工作。例如:

 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.4</version>
            <executions>
                <execution>
                    <id>repo1-dependency</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <connectionUrl>${my.repo1.url}</connectionUrl>
                        <scmVersion>${my.repo1.branch}</scmVersion>
                        <scmVersionType>branch</scmVersionType>
                        <checkoutDirectory>${project.build.directory}/${my.repo1}-${my.repo1.branch}</checkoutDirectory>
                    </configuration>
                    <goals>
                        <goal>checkout</goal>
                    </goals>
                </execution>
                <execution>
                    <id>repo2-dependency</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <connectionUrl>${my.repo2.url}</connectionUrl>
                        <scmVersion>${my.repo2.branch}</scmVersion>
                        <scmVersionType>branch</scmVersionType>
                        <checkoutDirectory>${project.build.directory}/${my.repo2}-${my.repo2.branch}</checkoutDirectory>
                    </configuration>
                    <goals>
                        <goal>checkout</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
于 2016-03-11T13:59:39.580 回答
2

我遇到了同样的情况,我找到了一个解决方案 - 使用您的代码:D- 可以在我的计算机上运行:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.xxx.internet</groupId>
    <artifactId>my-app</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Maven Quick Start Archetype</name>
    <url>http://www.mySite.de</url>
    <scm>
        <connection>scm:svn:http://svn-repo-adress:8080/repo/myDirectory</connection>
        <developerConnection>http://svn-repo-adress:8080/repo/myDirectory</developerConnection>
        <tag>HEAD</tag>
        <url>http://svn-repo-adress:8080/repo/myDirectory</url>
    </scm>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-scm-plugin</artifactId>
               <version>1.6</version>
               <configuration>
                 <goals>checkout</goals>
                 <checkoutDirectory>target/checkout</checkoutDirectory>
                 <username>username</username>
                 <password>userpassword</password>
               </configuration>
              <executions>
                <execution>
                    <id>check-out-project1</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>checkout</goal>
                    </goals>
                </execution>
            </executions>   
            </plugin>
        </plugins>
     </build>
</project>

在我在 cmd 控制台上执行“mvn scm:checkout”之后,它确实起作用了。

我认为重要的一点是在执行构建标签之前先添加 scm 标签。

于 2012-04-03T11:42:33.243 回答