【问题标题】:How to use master pom file to checkout all modules of a web application and build all modules如何使用主 pom 文件检查 Web 应用程序的所有模块并构建所有模块
【发布时间】:2012-03-05 18:25:22
【问题描述】:

我有一个依赖于多个模块的 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 文件配置为能够同时签出多个项目时间。请让我知道我在这里做错了什么,在此先感谢。

【问题讨论】:

  • 你有一个 Maven 存储库来发布你的工件吗?我认为您应该尝试在主程序集中使用依赖模块之前预先构建(并测试)它们。即使您只是使用本地 ~/.m2 存储库。这应该使您能够使用 maven-dependency-plugin 并下载直接编译和测试的工件(假设您有测试)。

标签: maven build-automation multi-module build-management


【解决方案1】:

我发现,如果将每个结帐放入其自己的&lt;execution&gt; ... &lt;/execution&gt; 并在其中单独的&lt;configuration&gt; ... &lt;/configuration&gt; 为他们工作。例如:

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

【讨论】:

  • 你能像我尝试的那样发布你的完整 pom 文件吗?我只执行了 1 次,它使用 scm 标签信息,而不是配置中的 connectionUrl。
【解决方案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 标签,然后再执行 build 标签。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多