On 2009-10-12, Christian Möller <dcmoel...@gmx.de> wrote:

>   <target name="init">
>     <echo>Hello from target 'init'</echo>
>     <appendExecutionOf target="extra-pre-test" toTarget="pre-test" />
>     <appendExecutionOf target="extra-post-test" toTarget="post-test" />
>   </target>

>   <target name="test" depends="init">
>     <antcall target="pre-test"/>
>     <echo>Hello from target 'test'</echo>
>     <antcall target="post-test"/>
>   </target>

> This is purposing the follwing: Adding execution of additional targets
> (here "extra-pre-test" and "extra-post-test") to some other targets
> (here "pre-test" and "post-test", respectively) depending on
> environmental properties (not shown here for simplicity).

> But unfortunalety this does not work as expected:

Your macro (which looks fine, that's why I snipped it) adds a new task
to a target in the currently executing Project instance.  In your test
you try to validate that it worked via antcall which creates a new
Project instance and re-parses the build file for that new instance -
your macro has never been executed for this instance and so the tasks
have never been added there.

If you try

<target name="test" depends="init, pre-test"/>

you should see you extra-pre-test.  Alternatively make pre-test and
post-test depend on init so the tasks get added in their Project
instance even in the presence of antcall.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to