Maven abstract. |
Tunning your Maven proyect |
Maven standard folders |
Managing dependencies with Maven |
Adding a nature in Eclipse |
Maven profiles inheritance |
DISCLAMER: THIS ENTRY STAYS HERE FOR HISTORICAL REASONS, BUT ITS CONTENT IS NOT ACCURATE (MILD WAY OF SAYING IT'S WRONG).
APOLOGIES FOR ANYBODY AFFECTED, IT WAS HONESTLY WRITTEN AND BADLY MAINTAINED.
As far as I have investigated, Maven profiles are not inherited, but there is a mechanism alike.
Let's build an example:
Parent pom.xml
<profiles>
<profile>
<id>profileA</id>
<activation>whatever</activation>
<build>[whatever]</build>
</profile>
<profile>
<id>profileB</id>
<activation>whatever</activation>
<build>[whatever]</build>
</profile>
</profiles>
Let's assume there's a child project, without specific profiles configuration.
It isn't a crazy idea imagine that if a project inherits from a parent pom like above, when activation conditions are met, child project should enjoy the build profiled configuration, but IT DOESN'T HAPPEN.
The only way to get something similar is configuring "profiles" and "activation" in child project, and the same "profiles" with same "id", with "resources" and "configuration" associated to that profile in parent pom.
This way, when a child project is compiling, profiles are activated and, with a profile active, it is actived in parent pom.
Example 2:
Parent pom.xml
<profiles>
<profile>
<id>profileA</id>
<build>[whatever]</build>
</profile>
<profile>
<id>profileB</id>
<build>[whatever]</build>
</profile>
</profiles>
Child pom.xml (assume a parent pom configuration in this project)
<profiles>
<profile>
<id>profileA</id>
<activation>whatever</activation>
</profile>
<profile>
<id>profileB</id>
<activation>whatever</activation>
</profile>
</profiles>
</profiles>
Notice that parent pom does not have activation conditions (they would not work either), and child pom does not have any configuration, because you wanted a parent pom for a common configuration.
This way, you have got something similar to Profiles inheritance.
Alberto Navarro.
@anavarro_prof
looking4q.blogspot.com