I am creating a maven 2 build for a project and I came up with profiles since the build has to be created for both different locations (say Berlin, Paris, North Pole) and different environment (Development, Production). Those are specified via properties. So for "North Pole" "DEV" I do:
-Dlocation=NorthPole -Denvironment=DEV
Now I would like to acivate my porfile based on both these properties, not just one. So I tried following:
<profiles>
<profile>
<id>NOrth Pole DEV</id>
<activation>
<property>
<name>location</name>
<value>NorthPole</value>
</property>
<property>
<name>environment</name>
<value>DEV</value>
</property>
</activation>
... <!-- Set some North Pole DEV specific stuff -->
</profile>
</profiles>
This doesn't work, maven expect to see at most one <property>
element there.
Please note I have another use for the properties as well so making it single property locationEnv
of value NorthPole-DEV
isn't what I want to have.
So is there any way or workaround or whatever else how to activate an profile based on combination of properties?
I am afraid there is no good solution to your problem (unless there are new Maven features I am not aware of).
In theory, you could introduce a derived property whose value is concatenated from the two properties you listed. However, the problem is that profiles are evaluated before properties defined in the pom, so such a derived property can't be used to activate a profile :-(
The best workaround I could think of for a similar problem was to activate the profile explicitly, and put the different combinations of command line parameters into separate batch/script files to make execution simpler and avoid mistyping issues.