Quantcast

Activation of profile based on property ! equaling a value

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Activation of profile based on property ! equaling a value

Richard Fuller
Maven: 2.2.1

I have a maven project with multiple modules where multiple profiles are
defined.  One of these profiles defines what environment we are currently
configured for.  In the parent project pom.xml file, I define a number of
properties based on the profile in use.  The problem is I need to do
something special (delete a file) every time unless I am in one environment.
 If I create a profile for every value of the environment property, it
works.  But I would like to do the following below.  I have examined the
code and it does check for a ! symbol, but I am not sure this only works on
system properties or will this work on user properties.  The following does
not work in Maven 2.2.1 and the profile is activated when I would think it
should not be.  Is this intended behavior or a bug?

<properties>
<environment>dev</environment>
</properties>

<profiles>
<profile>
<id>not_dev</id>
<activation>
<property>
<name>environment</name>
<value>!dev</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>not_dev_file</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Environment = ${environment}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Thanks in advance,
Wayne
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Activation of profile based on property ! equaling a value

Jörg Schaible
Richard Fuller wrote:

> Maven: 2.2.1
>
> I have a maven project with multiple modules where multiple profiles are
> defined.  One of these profiles defines what environment we are currently
> configured for.  In the parent project pom.xml file, I define a number of
> properties based on the profile in use.  The problem is I need to do
> something special (delete a file) every time unless I am in one
> environment.
>  If I create a profile for every value of the environment property, it
> works.  But I would like to do the following below.  I have examined the
> code and it does check for a ! symbol, but I am not sure this only works
> on
> system properties or will this work on user properties.  The following
> does not work in Maven 2.2.1 and the profile is activated when I would
> think it
> should not be.  Is this intended behavior or a bug?

Intendend. Profiles are evaluated before the rest of the POM (even before
looking for the parent), they cannot use properties (defined in the same POM
or inherited).

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

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

Re: Activation of profile based on property ! equaling a value

Richard Fuller
Intendend. Profiles are evaluated before the rest of the POM (even before
> looking for the parent), they cannot use properties (defined in the same
> POM
> or inherited).
>
> - Jörg
>
>
Thanks, that makes sense now.  But it poses another question, why does it
activate the profile if I remove the ! (not) symbol where the values are
equal and does not activate the profile if I remove the ! symbol and change
the property value where they are not equal?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Activation of profile based on property ! equaling a value

Richard Fuller
On Mon, Aug 2, 2010 at 4:27 PM, Richard Fuller <[hidden email]>wrote:

>
>
> Intendend. Profiles are evaluated before the rest of the POM (even before
>> looking for the parent), they cannot use properties (defined in the same
>> POM
>> or inherited).
>>
>> - Jörg
>>
>>
> Thanks, that makes sense now.  But it poses another question, why does it
> activate the profile if I remove the ! (not) symbol where the values are
> equal and does not activate the profile if I remove the ! symbol and change
> the property value where they are not equal?
>
>
Disregard, my test shows it does not work with the module or parent defining
the property.  Thanks.
Loading...