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: "ant call trigger can only be used from an ant build" from ant build
Date Thu, 10 May 2007 07:12:51 GMT
On 5/9/07, Jarosław Wypychowski <J.Wypychowski@icm.edu.pl> wrote:
>
> Hi All,
>
> I'm struggling with ivy 2.0.0-alpha-1 and ant (1.6.5/1.7.0) over Java
> 1.5.0_10/_11 and have run out of ideas for now. Hope someone might help
> with this.
>
> The scenario:
>
> I wanted to make a simple build system with ant/ivy. For that i used
> triggers on pre-resolve-dependency (ant-call). A trigger checks if given
> module is available (ivy:findrevision) and if not it calls a build on
> appropriate project (I know it is not a perfect solution - just
> started). Of course those sub-projects are also ivy-configured and use
> the same mechanism.
>
> I have tried running this scenario with the same project state (clearly
> checked out of SVN) and the results were something like that:
> machine | ant version | ant options | result - first run | second run
> A       | 1.6.5       |             | FAILURE            | SUCCESS
> A       | 1.6.5       | -verbose    | FAILURE            | SUCCESS
> A       | 1.6.5       | -debug      | SUCCESS            |
> B       | 1.6.5       |             | FAILURE            | SUCCESS
> B       | 1.7.0       |             | FAILURE (50%)      | SUCCESS
> B       | 1.6.5       | -verbose    | SUCCESS            |
> B       | 1.6.5       | -debug      | SUCCESS            |
>
> All failures are caused by ivy:resolve failing to find matching
> dependencies in internal projects. I have tried to debug this with ivy
> source - but then the scenario always succeeds.
> I've found following information in the ant logs for the failed
> scenarios:
>
> [ivy:resolve] ant call trigger can only be used from an ant build.
> Ignoring.
>
> And this is strange.
> From the source of ivy the ant project context is taken from ivy
> context. IvyContext is taken from ThreadLocal variable initialized on
> the first call to it or on demand.
>
> From the situation I guess that IvyContext is not initialized while the
> trigger should be called. This might mean that one of the sub calls are
> threaded by ant (antcall/ant/macro ?) for some reason and IvyContext for
> that thread has of course no context set - and therefore no ant project
> is available for ivy:resolve.
> But this is only a loose guess.
>
> Any ideas on how to solve this ?


Well, I think we'd need more information about your build itself. As you
have noticed, the context is attached to a thread local, but ant doesn't
create threads that often. So maybe this is due to the way you call Ivy (and
this is a bug in any case, but I'm just trying to narrow the problem).

For the while I have a "workaround"
> based on a handcrafted version of ivy compiled by hand that behaves
> correctly in all situations (I don't know why).


What did you change in your own ivy version?

And more general - maybe a ThreadLocal is not a good place for keeping
> IvyContext in ant environment ? Any thread created by ant is out of the
> scope of IvyContext at once (or am I wrong ?).


We have two kind of context in Ivy:
- ant based context, stored as ant references, which is used as context
between several ant tasks
- thread based context, which is used during a single call to one ivy
operation, to avoid passing some information all along all methods
We are suppose to be somewhat in control of threads created during an Ivy
operation... except when we call a plugin. We should document somewhere to
reattach the ivy context when creating a thread in an Ivy plugin, IF you
want this thread to be attached witht the current Ivy context, which is not
necessarily the case. In your case I think the problem happens before the
ant call in the trigger, so it seems we have a problem of context attachment
in Ivy itself.

BTW, did you try with Ivy 1.4.1? We have done quite a lot of refactoring in
Ivy 2.0, and it would help to know if it was working before or not.

Xavier

Best Regards.
>
> --jw
>
> --
> Jaroslaw Wypychowski
> Interdyscyplinarne Centrum Modelowania Matematycznego i Komputerowego UW
> jarwyp@icm.edu.pl
>
>


-- 
Xavier Hanin - Independent Java Consultant
Manage your dependencies with Ivy!
http://incubator.apache.org/ivy/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message