Is it possible to display a call to the "graph" of the ant extension point?

I have an extension point defined in ant:

<extension-point name="foo"/> 

Many tasks contribute to this issue in several imported ant files:

 <bindtargets targets="bar" extensionPoint="foo" /> 

However, I have a little lost exactly what tasks contribute. Is there a way for ant to report tasks that would be caused by this extension point? More generally, is there a way to display a β€œcall-graph” (or just a list of dependencies) of the ant task?

I tried using the detailed options for ant (-v etc.), with no luck.

thanks

+4
source share
3 answers

First of all, you can try to debug the ANT process in your IDE using remote debugging by adding some parameters to ANT_OPTS (mine is set to ~ / .profile):

http://blog.dahanne.net/2010/06/03/debugging-any-java-application/

And profiling can help. I found the Antro project on the ANT Wiki ...

http://sourceforge.net/projects/antro

Perhaps you can try. The project is said to be for ANT, which looks promising in solving your problem.

You can also use Yourkit Java Profiler to profile the CPU. YJP can display a graph of Java application calls, but I'm not sure if it is possible to find out which ANT targets.

The following document shows how to start a Java application using the YJP agent.

http://www.yourkit.com/docs/95/help/agent.jsp

0
source

I know two ways to get this information:

  • You can get the effective target / extension-point invocation sequence from the Ant console logger. To do this, put the logging Ant object in verbose mode by passing -verbose on the command line to Ant. There are two lines, one after the other, that are unloaded to the console just before most goals, since they invoke a script in your assembly:

    • A string that shows a summary of goals in a sequence of calls, starting with text, Build sequence for target(s) 'artifact' is [...] .
    • A string showing the detailed sequence of calls (nested targets and antcalls are included). This line begins with the text, Complete build sequence is [...] . This listing takes into account, as far as possible, the evaluation of any if and unless for each target specified at the point at which the line is written to the console.

    Just run your Ant construct, as usual, with the -verbose option, and your console should have the information you are looking for.

  • You can get a graphical representation of the call sequence using the Grand tool. However, it has not been updated for quite some time and thus does not support extension points (which is of interest to you here). He will interpret antcall's , ant and depend'encies . It does not evaluate the if and unless , but simply identifies a potential execution sequence β€” more of a dependency hierarchy than the actual schedule of calls. The project is on Github, so updating to support extension points may not be too complicated.

    Graphics are displayed using Graphviz.

For the actual call sequence, use option 1.

0
source

This is pretty messy, but it works. Ant is actually pretty easy to script, and if you use at least Java 6 (or it could be Java 7), javascript support is built-in and therefore can be used right out of the box. This defines a task that will reflect the dependencies of any goal in the order of the call:

 <scriptdef name="listdepends" language="javascript"> <attribute name="target"/> <![CDATA[ var done = []; var echo = project.createTask("echo") function listdepend(t) { done.push(t.getName()); var depends = t.getDependencies(); while (depends.hasMoreElements()) { var t2 = depends.nextElement(); if (done.indexOf(t2)==-1) listdepend(project.getTargets().get(t2)); } echo.setMessage(t.getName()); echo.perform(); } var t = attributes.get("target"); if (t!=null) { var targ = project.getTargets().get(t); listdepend(targ); } ]]> </scriptdef> 

In your case, you can create a new target (or not) and call it like this:

  <target name="listfoo"> <listdepends target="foo"/> </target> 

As I said, this is somewhat messy. This is probably not very fast (although if your target is not causing thousands of others, it is probably not noticeably slow). It will not process antcall tasks (although it can be changed so easily) or respond to if and except attributes. If the dependencies are too far away, this can lead to a limitation of the depth of the recursion (but I doubt that any project has them deeply embedded).

An array is used to make sure that each dependency is specified once (ant will only run them once).

0
source

All Articles