我有一个依赖于多个模块的 Web 应用程序。所以要构建它,我有一个主 pom.xml 文件。我想要这个 pom 文件做的是 check out 所有模块。
下面是我的 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:结帐和 mvn scm:checkout -check-out-project1 但它给了我错误:
无法运行结帐命令:无法加载 scm 提供程序。您需要定义一个 connectionUrl 参数。
我不明白为什么会发生这种情况,因为我已经在 pom 文件中定义了 connectionUrl 参数,我想要得到的想法是让 pom 文件配置为能够同时 checkout 多个项目。请让我知道我在这里做错了什么,在此先感谢。
最佳答案
我发现如果将每个结帐放入自己的 <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>
关于maven - 如何使用主 pom 文件检查 Web 应用程序的所有模块并构建所有模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9571859/