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
)?
Here is my Pom entry
<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
Open Maven settings. m2 directory where %USER_HOME% represents the user home directory. If settings. xml file is not there, then create a new one. Add test profile as an active profile using active Profiles node as shown below in example.
A profile in Maven is an alternative set of configuration values which set or override default values. Using a profile, you can customize a build for different environments. Profiles are configured in the pom. xml and are given an identifier.
Based on the documentation and discussion here, try separating profile names with a comma:
mvn install -P Test1,Test2
Mifeet's answer is correct, but in Windows PowerShell you should quote parameters, otherwise you'll get "unknown lifecycle phase" error.
mvn install -P 'Test1,Test2'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With