Browse Source

change implementation of handling importing files top-level tasks

to be less hachy


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275250 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 22 years ago
parent
commit
4d89b46d4d
2 changed files with 13 additions and 32 deletions
  1. +3
    -29
      src/main/org/apache/tools/ant/Target.java
  2. +10
    -3
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java

+ 3
- 29
src/main/org/apache/tools/ant/Target.java View File

@@ -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 <code>null</code>.
*/
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);


+ 10
- 3
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -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));


Loading…
Cancel
Save