You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Richard Fuller <rw...@gmail.com> on 2010/08/02 22:16:50 UTC
Activation of profile based on property ! equaling a value
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
Re: Activation of profile based on property ! equaling a value
Posted by Richard Fuller <rw...@gmail.com>.
On Mon, Aug 2, 2010 at 4:27 PM, Richard Fuller <rw...@gmail.com>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.
Re: Activation of profile based on property ! equaling a value
Posted by Richard Fuller <rw...@gmail.com>.
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?
Re: Activation of profile based on property ! equaling a value
Posted by Jörg Schaible <jo...@gmx.de>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org