如何在一个maven命令中调用两个不同的配置文件?
问题描述:
我在pom.xml
中有两个用于不同环境的配置文件,我必须运行mvn -PTest1 install
和mvn -PTest2 install
命令才能使用这些配置文件.我们可以将两个单独的maven命令集成到一个命令中吗(例如mvn clean install
)?
I have two profiles for different environments in pom.xml
, I have to run mvn -PTest1 install
and mvn -PTest2 install
command to get these profiles in use. Can we integrate two separate maven commands in a single one (like mvn clean install
)?
这是我的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>
使用单个命令管理哈德森工作将很有帮助
It will helpfull to manage hudson job using single command
答
基于此处,请尝试用逗号分隔配置文件名称:
Based on the documentation and discussion here, try separating profile names with a comma:
mvn install -P Test1,Test2