You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Yves Martin <yv...@elca.ch> on 2004/12/13 18:06:50 UTC
Internal AntCall and references
Hello,
I have created a task that must be 'context' aware. Currently, I stores
information (Java objects) in a ugly static map in my task and it works
well.
To clean it, I decided to use project references but it does not work with
'antcall':
target A
antcall B
MyTask{getReference X}
target B
MyTask{setReference X}
Is there a better way to implement a global storage ?
Thank you in advance. Regards,
--
Yves Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Internal AntCall and references
Posted by Yves Martin <yv...@elca.ch>.
Stefan Bodewig <bo...@apache.org> writes:
> On Mon, 13 Dec 2004, Yves Martin <yv...@elca.ch> wrote:
>
>> To clean it, I decided to use project references but it does not
>> work with 'antcall':
>
> This is because you set the reference in a different Project instance
> than you try to read it in.
>
>> target A
>> antcall B
>> MyTask{getReference X}
>>
>> target B
>> MyTask{setReference X}
>>
>> Is there a better way to implement a global storage ?
>
> Option (1) don't use antcall at all.
I think it is impossible. My target A looks like to:
target A
Job before
Loop { antcall B }
MyTask{getReference X}
What I may do is to create my own 'call' task that calls a target in the same
project (as depends attribute does I guess). Is it a good idea ?
> Option (2) use a Map as your global storage and set this one as
> reference before invoking antcall (with inheritrefs=true) and have
> MyTask not set the reference in the project, but add it to your global
> storage.
I will try that also.
> This also requires you Map to be not Cloneable since otherwise B will
> only see a copy of your global storage and be unable to write to it.
> Ant tries its best to make it hard for "subbuilds" to affect their
> "parent build".
Yes, I understand that perfectly.
Regards
--
Yves Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: Internal AntCall and references
Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 13 Dec 2004, Yves Martin <yv...@elca.ch> wrote:
> To clean it, I decided to use project references but it does not
> work with 'antcall':
This is because you set the reference in a different Project instance
than you try to read it in.
> target A
> antcall B
> MyTask{getReference X}
>
> target B
> MyTask{setReference X}
>
> Is there a better way to implement a global storage ?
Option (1) don't use antcall at all.
Option (2) use a Map as your global storage and set this one as
reference before invoking antcall (with inheritrefs=true) and have
MyTask not set the reference in the project, but add it to your global
storage.
This also requires you Map to be not Cloneable since otherwise B will
only see a copy of your global storage and be unable to write to it.
Ant tries its best to make it hard for "subbuilds" to affect their
"parent build".
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org