Pas*_*ent 14
要使用配置文件实现此功能,您可以使用两个配置文件,一个<activeByDefault>包含所有模块,另一个配置文件仅包含所需模块.像这样的东西:
<profiles>
<profile>
<id>all</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>module-1</module>
...
<module>module-n</module>
</modules>
</profile>
<profile>
<id>module-2</id>
<modules>
<module>module-2</module>
</modules>
</profile>
<profiles>
Run Code Online (Sandbox Code Playgroud)
然后像这样调用它:
mvn -Pmodule-2 package
Run Code Online (Sandbox Code Playgroud)
这里有两点需要注意:
<modules>在"默认"配置文件中移动POM(因为<modules>配置文件只是附加的,它们不会隐藏POM中声明的模块).<activeByDefault>,如果没有其他活动,则将选择"默认"配置文件,但如果没有其他内容则将其取消激活.甚至可以参数化模块的名称并将其作为属性传递:
<profiles>
...
<profile>
<id>module-x</id>
<activation>
<property>
<name>module-name</name>
</property>
</activation>
<modules>
<module>${module-name}</module>
</modules>
</profile>
<profiles>
Run Code Online (Sandbox Code Playgroud)
并像这样调用maven:
mvn -Dmodule-name=module-2 package
Run Code Online (Sandbox Code Playgroud)
但这是一个糟糕的实现恕我直言,我更喜欢-pl"高级"反应堆选项(更少的xml,更多的功能和灵活性):
mvn -pl module-2 package
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5014 次 |
| 最近记录: |