You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jean-Louis Boudart <je...@gmail.com> on 2009/11/09 13:28:49 UTC

Querying ant context

Hi there,

The new abstraction layer on ProjectHelper is awesome !

But now i'm wondering how can we make (in a generic way) reports for our
builds?
There were a few existing projects (AntDoc for example) but there were all
XML based.
What solution could we use to generate such report?

I've tried to play with the infos accessible in the Project instance.
It seems that we are able to access every task used/defined in a target
(using the method getTasks() on Target.java). Here we can have a lot of
infos.
However it seems that we're not able to access all tasks defined outside of
the target.
A quick example:

<project>
    <import file="myfile"/>
    <myTask/>

    <target name="foobar">
        <thisTaskCanBeDocumentedBecauseWeAreInsideATarget/>
    </target>
</project>

Here we're not able to know the task defined outside the target (import,
myTask in the previous example).
All this tasks seems to be attached to a virtual target (a target without
name) referenced by the XMLContext instance which is all the time
overwritten during <import>.
Did i miss something?

Any idea of how this could be done?


Thanks for you help.

-- 
Jean Louis Boudart
Independent consultant
Project Lead http://www.easyant.org

Re: Querying ant context

Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-11-09, Jean-Louis Boudart <je...@gmail.com> wrote:

> Here we're not able to know the task defined outside the target (import,
> myTask in the previous example).
> All this tasks seems to be attached to a virtual target (a target
> without name)

Almost.  It's name is the empty string.

> referenced by the XMLContext instance which is all the time
> overwritten during <import>.  Did i miss something?

It is overwritten, executed at the end of import and restored.

> Any idea of how this could be done?

You get all tasks except for the import tasks from the target named "",
but for the imports and in particular for the contents of import I don't
see any way.  Handling of import is too tightly integrated with parsing
the project, the rest of Ant's classes isn't even aware of it.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org