Bug 31487 - execution of top level tasks in imported files get delayed by targets
Summary: execution of top level tasks in imported files get delayed by targets
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: nightly
Hardware: Other All
: P3 major (vote)
Target Milestone: 1.6.3
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-30 14:32 UTC by Stefan Bodewig
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Bodewig 2004-09-30 14:32:57 UTC
I've stripped down the problem mentioned in
<http://marc.theaimsgroup.com/?l=ant-user&m=109655281326491&w=2>.

Suppose we have

outer.xml
=========
<project name="outer">
  <import file="inner.xml"/>
  <property name="foo" value="${bar}"/>
  <echo>foo is ${foo}</echo>
</project>

inner.xml
=========
<project name="inner">
  <target name="baz"/>
  <property name="bar" value="bar is set"/>
  <echo>bar is ${bar}</echo>
</project>

This results in

[bodewig@bodewig tmp]$ ant -f outer.xml 
Buildfile: outer.xml
     [echo] foo is ${bar}
     [echo] bar is bar is set

BUILD SUCCESSFUL
Total time: 1 second


Now remove the target from inner.xml

[bodewig@bodewig tmp]$ ant -f outer.xml 
Buildfile: outer.xml
     [echo] bar is set
     [echo] foo is bar is set

BUILD SUCCESSFUL
Total time: 1 second

So if the imported file contains targets, its top level task get delayed until
the ones of the importing file are done.  If it doesn't, they get executed
immediately.  This is clearly wrong, both should behave the same way.

One can argue which way is the correct one, my vote would be for "execute
immediately" since it seems more intuitive.
Comment 1 Stefan Bodewig 2004-09-30 14:33:37 UTC
You don't even need properties, just the echos are enough to show the problem.
Comment 2 Peter Reilly 2004-09-30 14:50:15 UTC
A work-around is to always place targets after top-level
types/tasks.
Comment 3 Peter Reilly 2004-09-30 17:08:10 UTC
Fixed in HEAD.  (Need to sync to 1.6 branch?)