Maven 如何使用主pom文件签出web应用程序的所有模块并构建所有模块

Maven 如何使用主pom文件签出web应用程序的所有模块并构建所有模块,maven,build-automation,multi-module,build-management,Maven,Build Automation,Multi Module,Build Management,我有一个web应用程序,它依赖于几个模块。为了构建它,我有一个主pom.xml文件。我想要这个pom文件做的是签出所有模块。 下面是我的pom文件 <executions> <execution> <id>check-out-project1</id> <phase>generate-sources</phase>

我有一个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>

退房项目1
生成源
结账
${project.build.directory}/module1
scm:svn:svn://svnserver/svn/module1/trunk
用户名
密码
退房项目2
生成源
结账
${project.build.directory}/module1
scm:svn:svn://svnserver/svn/module1/trunk
用户名
密码
我尝试了mvn scm:checkout和mvn scm:checkout-check-out-project1,但它给了我错误: 无法运行签出命令:无法加载scm提供程序。您需要定义connectionUrl参数。


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

我也遇到了同样的情况,我找到了一个解决方案——使用你的代码: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>

4.0.0
互联网
我的应用程序
罐子
1.0-快照
Maven快速启动原型
http://www.mySite.de
scm:svn:http://svn-repo-adress:8080/repo/myDirectory
http://svn-repo-adress:8080/repo/myDirectory
头
http://svn-repo-adress:8080/repo/myDirectory
UTF-8
UTF-8
org.apache.maven.plugins
maven scm插件
1.6
结账
目标/结帐
用户名
用户密码
退房项目1
生成源
结账
在我在cmd控制台上执行“mvnscm:checkout”之后,它就工作了


我认为重要的一点是在执行build标记之前,首先添加scm标记。

我发现如果将每个签出放在自己的
并将个人
放入为他们工作。例如:

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

org.apache.maven.plugins
maven scm插件
1.9.4
repo1依赖关系
生成源
${my.repo1.url}
${my.repo1.branch}
分支
${project.build.directory}/${my.repo1}-${my.repo1.branch}
结账
repo2依赖性
生成源
${my.repo2.url}
${my.repo2.branch}
分支
${project.build.directory}/${my.repo2}-${my.repo2.branch}
结账

您是否有maven存储库来发布您的工件?我认为,在主程序集中使用依赖模块之前,应该先对它们进行预构建(并进行测试)。即使您只是使用本地~/.m2回购。这应该使您能够使用maven dependency plugin并直接下载编译和测试的工件(假设您有测试)。您可以像我尝试的那样发布完整的pom文件,我只执行了1次,并且它使用scm标记信息,而不是配置中的connectionUrl。