You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Carlos Alonso <ca...@unkasoft.com> on 2008/09/09 08:56:26 UTC
Setting a property value from an Ant task
Hi All.
I have the following situation: I have two maven properties that should
take a value or another depending on a boolean given from command line
and I don't know how to achieve it.
I'm trying to achieve this by using the following ant task:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b2</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<tasks>
<taskdef name="if"
classname="net.sf.antcontrib.logic.IfTask"
classpathref="maven.plugin.classpath" />
<if>
<equals
arg1="${variable_from_command_line}" arg2="true" />
<then>
<property name="property1"
value="val1 "/>
<property name="property2"
value="val2 "/>
</then>
<else>
<property name="property1"
value="val3 "/>
<property name="property2"
value="val4 "/>
</else>
</if>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Properties seem to be set up successfully but only seem to be available
within the ant task execution, but not exported to the maven one.
Any input?
Thanks in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Setting a property value from an Ant task
Posted by Wayne Fay <wa...@gmail.com>.
Using Ant's if task for this is not the proper "Maven" approach...
Instead, use profiles.
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
Wayne
On Mon, Sep 8, 2008 at 11:56 PM, Carlos Alonso <ca...@unkasoft.com> wrote:
> Hi All.
>
> I have the following situation: I have two maven properties that should
> take a value or another depending on a boolean given from command line
> and I don't know how to achieve it.
> I'm trying to achieve this by using the following ant task:
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-antrun-plugin</artifactId>
> <dependencies>
> <dependency>
> <groupId>ant-contrib</groupId>
> <artifactId>ant-contrib</artifactId>
> <version>1.0b2</version>
> </dependency>
> </dependencies>
> <executions>
> <execution>
> <phase>validate</phase>
> <configuration>
> <tasks>
> <taskdef name="if"
> classname="net.sf.antcontrib.logic.IfTask"
> classpathref="maven.plugin.classpath" />
>
> <if>
> <equals
> arg1="${variable_from_command_line}" arg2="true" />
> <then>
> <property name="property1"
> value="val1 "/>
> <property name="property2"
> value="val2 "/>
> </then>
>
> <else>
> <property name="property1"
> value="val3 "/>
> <property name="property2"
> value="val4 "/>
> </else>
> </if>
> </tasks>
> </configuration>
> <goals>
> <goal>run</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> Properties seem to be set up successfully but only seem to be available
> within the ant task execution, but not exported to the maven one.
> Any input?
>
> Thanks in advance.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org