ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <xavier.ha...@gmail.com>
Subject Re: Ivy triggers and scope of properties
Date Fri, 18 Jan 2008 16:09:28 GMT
On Jan 17, 2008 4:43 PM, Vasco Lemoine <vasco.lemoine@imc.nl> wrote:

> Hi,
>
> I'm struggling with a problem concerning ivy triggers. What I want to is
> the following. As a in a pre-resolve trigger i want to concatenate the
> module that are resolve (transitively).
>
> this is in my ivy-setting.xml
>
> <triggers>
>        <ant-call target="ivy-pre-resolve-dependency" prefix="dep"
>                  event="pre-resolve-dependency" />
> </triggers>
>
> this is in my build file:
>
> <property name="foo" value="" />
>
> <target name="ivy-pre-resolve-dependency">
> <echo>foo=${foo}</echo>
> <var name="bar" value="${foo}"/>
> <echo>bar=${bar}</echo>
> <if>
> <length string="${bar}"when="greater"length="0" />
> <then>
>  <var name="bar"value="${bar},{dep.module}" />
> </then>
> <else>
>  <var name="bar" value="${dep.module}" />
> </else>
> </if>
> <propertycopy name="foo" from="bar" override="true"/>
> <echo>
>  module=${dep.module}
>  bar=${bar}
>  foo=${foo}
> </echo>
> </target>
>
>
>
> output is:(having declared dependency: this->module1->module2)
>
> foo=
> bar=
> module=module1
> bar=module1
> foo=module1
>
> foo=
> bar=
> module=module2
> bar=module2
> foo=module2
>
> instead of:
>
> foo=
> bar=
> module=module1
> bar=module1
> foo=module1
>
> foo=module1
> bar=module1
> module=module2
> bar=module1,module2
> foo=module1,module2
>
> Is there some way of getting variables or properties to the scope from
> which the trigger was generated.

I'm a bit surprised by the result, but I don't know the var and propertycopy
task well enough, and it may be related to what they do. Did you try to
simulate the Ivy triggers in a pure Ant script (without Ivy) to see what
happens:
<target name="test">
  <antcall target="foo">
    <param name="dep.module" value="module1"/>
  </antcall>
  <antcall target="foo">
    <param name="dep.module" value="module2"/>
  </antcall>
</target>

If this works, then it's Ivy that doesn't do what expected. If it doesn't,
then Ivy has nothing to do with your problem, and you should look for
another solution, like using a script or a custom Ant task (in Java) and a
true variable (which would BTW make things much more readable IMHO).

Xavier

>
>
> By the way the var and propertycopy are from the antcontrib library.
>
> Thanx Vasco
>
>
>
>
>


-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message