Overriding a profile in a child POM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Overriding a profile in a child POM

Shahim Essaid
Hi,

I tested the possibility of overriding a profile in a child POM by using
the same profile id but it doesn't work. The profiles get merged.

Is there a simple way to fully override a profile in a child POM?

Merging (i.e. composing) profiles is very useful but I can get this
behavior by activating different profiles (with different ids) on the same
property. It looks like creating a child profile with the same id has
exactly the same behavior.

I'm sure this behavior is something that can't be change at this point but
it might be useful to be able to override a profile by id to give some
additional options for how to design a build through inheritance. Having to
override individual plugins and executions inherited from a parent profile
can get a little tedious.

I don't have a specific use-case in mind. I was just trying to understand
all my options before thinking about how to compose and override my build
behaviors.

Best,
Shahim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding a profile in a child POM

Jim Klo
I’m not sure if it’s the correct way to do it, but I’ve done this using negated activation using properties

parent pom:

        <profile>
            <id>build-all-my-docs</id>
            <activation>
                <property>
   <name>build-all-docs</name>
</property>
            </activation>
        </profile>


child pom:
<profile>
            <id>build-dev-docs</id>
            <activation>
                <property>
                    <name>!build-all-docs</name>
                </property>
            </activation>
        </profile>

then:
mvn -Dbuild-all-docs=true help:active-profiles


will show you that the parent profile is activate and the child profile is inactive

and:
mvn  help:active-profiles

should show the inverse.



Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International
t. @nsomnac

On Feb 22, 2017, at 11:14 AM, Shahim Essaid <[hidden email]> wrote:

Hi,

I tested the possibility of overriding a profile in a child POM by using
the same profile id but it doesn't work. The profiles get merged.

Is there a simple way to fully override a profile in a child POM?

Merging (i.e. composing) profiles is very useful but I can get this
behavior by activating different profiles (with different ids) on the same
property. It looks like creating a child profile with the same id has
exactly the same behavior.

I'm sure this behavior is something that can't be change at this point but
it might be useful to be able to override a profile by id to give some
additional options for how to design a build through inheritance. Having to
override individual plugins and executions inherited from a parent profile
can get a little tedious.

I don't have a specific use-case in mind. I was just trying to understand
all my options before thinking about how to compose and override my build
behaviors.

Best,
Shahim


smime.p7s (5K) Download Attachment
Loading...