[英]How do I invoke two different profiles in one maven command?
I have two profiles for different environments in pom.xml<\/code> , I have to run
mvn -PTest1 install<\/code> and
mvn -PTest2 install<\/code> command to get these profiles in use.
我在
pom.xml<\/code>中有两个用于不同环境的配置文件,我必须运行
mvn -PTest1 install<\/code>和
mvn -PTest2 install<\/code>命令才能使用这些配置文件。
Can we integrate two separate maven commands in a single one (like
mvn clean install<\/code> )?
我们可以将两个单独的 maven 命令集成到一个命令中(例如
mvn clean install<\/code> )吗?
Here is my Pom entry这是我的 Pom 条目
<profiles>
<profile>
<id>Test1</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.5</jdk>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
<property>
<name>sparrow-type</name>
<value>African</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>
com.endeca
</groupId>
<artifactId>
endeca_navigation_Test1
</artifactId>
<version>
6.1
</version>
<!--<version>stable</version> -->
<scope>
compile
</scope>
</dependency>
</profile>
<profile>
<id>Test2</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.5</jdk>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
<property>
<name>sparrow-type</name>
<value>African</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>
com.endeca
</groupId>
<artifactId>
endeca_navigation_Test2
</artifactId>
<version>
6.1
</version>
<!--<version>stable</version> -->
<scope>
compile
</scope>
</dependency>
</dependencies>
</profile>
</profiles>
根据此处<\/a>的文档<\/a>和讨论,尝试用逗号分隔配置文件名称:
mvn install -P Test1,Test2
Mifeet 的回答<\/a>是正确的,但在 Windows PowerShell 中您应该引用参数,否则您将收到“未知生命周期阶段”错误。
mvn install -P 'Test1,Test2'
For me Mifeet's answer isn't working.对我来说,Mifeet 的回答不起作用。 I get "unknown lifecycle phase Test2".我得到“未知的生命周期阶段 Test2”。 For me this is working:对我来说,这是有效的:
mvn install -PTest1 -PTest2
Based on the maven help command基于 maven help 命令
-P,--activate-profiles <arg> Comma-delimited list of profiles to activate
This is not an answer, is to disccuss, how looks like the output of the command that works I try the @naXa, and I think it works only show this messages这不是一个答案,而是讨论,我尝试@naXa 的命令的输出看起来如何,我认为它只显示此消息
[WARNING] The requested profile "'test" could not be activated because it does not exist.
[WARNING] The requested profile "normal'" could not be activated because it does not exist.
Command that I run我运行的命令
mvn test -P 'test,normal'
so, the question is how do I identy that already run both profiles?所以,问题是我如何识别已经运行两个配置文件?
When I run the commando with double quotes doesn't show the warnings but I think that only execute the normal profile, because it shows当我用双引号运行突击队时不会显示警告,但我认为只执行普通配置文件,因为它显示
[INFO] Executing tasks
[echo] Using env.properties
[INFO] Executed tasks
Something similar occurs when I use the versions propouse by @dermoritz, @sendon1982 and @Mifeet当我使用@dermoritz、@sendon1982 和@Mifeet 提出的版本时,也会发生类似的情况
mvn test -Ptest -Pnormal
mvn test -Ptest,normal
So I am not sure how should be look.所以我不确定应该怎么看。 Thanks for your help谢谢你的帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.