diff --git a/src/main/org/apache/tools/ant/Target.java b/src/main/org/apache/tools/ant/Target.java index d82ee5568..a729a1a28 100644 --- a/src/main/org/apache/tools/ant/Target.java +++ b/src/main/org/apache/tools/ant/Target.java @@ -80,15 +80,11 @@ public class Target implements TaskContainer { private List dependencies = null; /** Children of this target (tasks and data types). */ private List children = new ArrayList(); - /** Position in task list */ - private int taskPosition = 0; /** Project this target belongs to. */ private Project project; - /** Description of this target, if any. */ + private String description = null; - /** Imported tasks/types being added */ - private List importedTasks = null; /** Sole constructor. */ public Target() { @@ -170,35 +166,13 @@ public class Target implements TaskContainer { return name; } - /** - * This method called when an import file is being processed. - * The top-level tasks/types are placed in the importedTasks array. - * - */ - public void startImportedTasks() { - importedTasks = new ArrayList(); - } - /** * Adds a task to this target. * * @param task The task to be added. Must not be null. */ public void addTask(Task task) { - if (importedTasks != null) { - importedTasks.add(task); - } else { - children.add(task); - } - } - - /** - * This method called when an import file is being processed. - * The top-level tasks/types are placed in the importedTasks array. - * - */ - public void endImportedTasks() { - children.addAll(taskPosition + 1, importedTasks); + children.add(task); } /** @@ -354,7 +328,7 @@ public class Target implements TaskContainer { */ public void execute() throws BuildException { if (testIfCondition() && testUnlessCondition()) { - for (taskPosition = 0; + for (int taskPosition = 0; taskPosition < children.size(); ++taskPosition) { Object o = children.get(taskPosition); diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index 316b52664..343e4ef52 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -154,9 +154,16 @@ public class ProjectHelper2 extends ProjectHelper { if (getImportStack().size() > 1) { // we are in an imported file. context.setIgnoreProjectTag(true); - context.getCurrentTarget().startImportedTasks(); - parse(project, source, new RootHandler(context, mainHandler)); - context.getCurrentTarget().endImportedTasks(); + Target currentTarget = context.getCurrentTarget(); + try { + Target newCurrent = new Target(); + newCurrent.setName(""); + context.setCurrentTarget(newCurrent); + parse(project, source, new RootHandler(context, mainHandler)); + newCurrent.execute(); + } finally { + context.setCurrentTarget(currentTarget); + } } else { // top level file parse(project, source, new RootHandler(context, mainHandler));