在调用maven构建来指定备用文件来代替标准pom.xml文件名时是否存在参数?
基本上,我需要使用各种配置来运行maven构建的 test 目标。现在我不得不使用外部脚本来更新具有此配置的标准pom,然后恢复文件。我宁愿只能维护几个单独的配置文件,并使用我需要的特定文件调用maven。
我想知道的是,是否有某种方法可以覆盖pom.xml,例如
mvn clean test (uses standard pom.xml)
mvn clean test -Dmaven.source=alternate.xml
mvn clean test -Dmaven.source=alternate2.xml
这可能吗?
答案 0 :(得分:91)
使用-f选项:
mvn -f <other pom file>
答案 1 :(得分:8)
我将保留接受的答案,因为它是使用备用pom文件运行的正确解决方案。但是,对于上面描述的用例,我现在觉得正确的方法是在pom文件中使用maven配置文件。
使用配置文件,所有版本的测试配置都可以包含在主pom文件中,然后按如下方式执行:
mvn clean test -PstandardConfig
mvn clean test -PalternateConfig
mvn clean test -PanotherConfig
答案 2 :(得分:0)
当我得到最终答案时,我发现了这个非常有趣的解决方案。我遵循以下方法:-
mvn -f yourPomfil.xml目标
可以清洁,验证,打包,安装,部署和其他Maven目标的目标