The maven project I’m working on has profiles for different environments, such as testing, development and deployment.
<profiles> <profile> <id>test</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <db.host>testdb.mycompany.com</db.host> <db.name>projectx</db.name> </properties> </profile> <profile> <id>development</id> <properties> <db.host>127.0.0.1</db.host> </properties> </profile> </profiles>
To activate multiple profiles at run time, you use the command line option -P
mvn test -P test,development
Or inside eclipse with m2e, you can configure a list of active profiles under Run Configurations.
However, with Mule Studio, if you run the project as a Mule Application with Maven, there are no options to select maven profiles.
The way to get around this is to edit the maven profiles to be activated by a property or a file. In my case, I updated my pom.xml to
<profiles> <profile> <id>Test</id> <activation> <activeByDefault>true</activeByDefault> <property> <name>env</name> <value>test</value> </property> </activation> <properties> <db.host>testdb.mycompany.com</db.host> <db.name>projectx</db.name> </properties> </profile> <profile> <id>Development</id> <activation> <file> <exists>.git</exists> </file> </activation> <properties> <db.host>127.0.0.1</db.host> </properties> </profile> </profiles>
The test profile is activated by setting the system property env to test. This is done in Mule Studio under Windows -> Preferences -> Mule Studio -> Maven Settings. In the “MAVEN_OPTS environment variable” text box, add -Denv=test. The development profile is activated by the existence of a .git file in the project root. Now when I run this as a mule+maven project in eclipse, the properties from both of these profiles are available.
You might ask wouldn’t it be easier to just add -P test,development to the MAVEN_OPTS text box? Yes it would definitely be, but mule studio complained about -P being an unrecognized option.
PS. I’m using mule studio 3.5.