Possible Duplicate:
How do I exclude certain modules from a maven build using the commandline
我正在一个包含多个模块(和子模块)的 pom 文件中运行 maven clean install
。我想知道是否可以运行 Maven 构建但在命令行上指定从构建中跳过模块(目前我从构建中手动排除它们,但我更喜欢通过命令行执行此操作)。
我知道使用 -pl 你可以有选择地选择项目,但我想要的是有选择地排除(以黑名单方式)一些。
你可以有一个单独的 <modules>
配置文件中的部分,并在命令行中激活您需要的配置文件。
例子:
<profiles>
<profile>
<id>profile-1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>...</modules> <!-- module set 1 -->
</profile>
<profile>
<id>profile-2</id>
<modules>...</modules> <!-- module set 2 -->
</profile>
</profiles>
现在,根据您当前的需要,执行
mvn install
mvn install -P profile-2
请注意,您必须仔细考虑,排除的模块不能有跨配置文件依赖。