I know it’s impossible to “chain” profile declaration.
It’s possible to do what I want (but not completely) with System properties in command line like mvn -Dvar=value .
And then use this:
<activation>
<property>
<name>var</name>
<value>value</value>
</property>
</activation>
or to activate simultaneously several profiles with -P profile1, profile2
In fact I have 4 profiles and I want to create a fifth profile with all the aspectj part (plugins, dependencies, …) which should be activated only if profile 1, 2 or 3 is activated. Like that I don’t have redundant plugins and dependencies declarations.
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
...
</build>
</profile>
<profile>
<id>profile2</id>
<build>
...
</build>
</profile>
<profile>
<id>profile3</id>
<build>
...
</build>
</profile>
<profile>
<id>profile4</id>
<build>
<plugins>
<plugin>
...
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>aop</id>
<build>
<plugins>
<plugin>
...
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
...
</dependency>
<dependency>
...
</dependency>
</dependencies>
</profile>
The problem is that profile 1 is the default profile and even it should be possible to do it without command line args. I tried with defining a value but it doesn’t work because activation property only works with system properties.
Am I wrong? Is there another way to do it?
Thanks
Maven won’t help you there, you can have no dependencies or inheritance between profiles, see also my recent answer to a related question.
You can explicitly turn profiles on or off, but there is no way to define any relation between them. Maven is not ant, which is usually a good thing, but this is one of the cases where I think it should be more like ant.
From Introduction to Build Profiles:
None of these is helpful to define any relation between the profiles (Project properties can’t be used because Profiles are evaluated while the Project is built). So your only options are to
-PsyntaxDefaultProfileSelector, as outlined in my previous answer