It seems that the task must be executed before. If you add a >depends="sub"< on the main target, that works.
So the question is: when are id's stored? The parsing is done via ProjectHelper's and their SAX-Parser-Handlers. On the first view I would say, that the id is stored while parsing - so before exucution. Jan > -----Ursprüngliche Nachricht----- > Von: Gintautas Grigelionis [mailto:g.grigelio...@gmail.com] > Gesendet: Montag, 28. Oktober 2019 14:25 > An: Ant Developers List > Betreff: Script task specification > > The documentation of the script task states: > > "All items (tasks, targets, etc) of the running project are accessible > from the script, using either their name or id attributes (as long as > their names are considered valid Java identifiers, that is). " > > However, the following fails: > > <?xml version="1.0"?> > <project name="test" default="main" basedir="."> > <target name="sub"> > <echo id="foo">Executing a task</echo> > </target> > > <!-- tests the script stuff --> > <target name="main"> > <script language="javascript"><![CDATA[ > foo.setMessage("I'm a foo!") > sub.execute() > ]]></script> > </target> > </project> > > Surely there are more limitations? Besides, failure modes are different > in Rhino (unable to create engine) and Nashorn (reference not defined). > > Regards, > Gintas --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org For additional commands, e-mail: dev-h...@ant.apache.org