Browse Source

This is a fractional refactor of the class to split task creation from adding it to the list of tasks we know about. As the factored out method is private, external routines still cannot create tasks that arent added to the list...this change does not alter the external API of Project, just makes it possible.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273317 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 23 years ago
parent
commit
0695ed1416
1 changed files with 24 additions and 3 deletions
  1. +24
    -3
      src/main/org/apache/tools/ant/Project.java

+ 24
- 3
src/main/org/apache/tools/ant/Project.java View File

@@ -1087,8 +1087,9 @@ public class Project {
}

/**
* Creates a new instance of a task.
*
* Creates a new instance of a task, adding it to a list of
* created tasks for later invalidation. This causes all tasks
* to be remembered until the containing project is removed
* @param taskType The name of the task to create an instance of.
* Must not be <code>null</code>.
*
@@ -1099,6 +1100,27 @@ public class Project {
* creation fails.
*/
public Task createTask(String taskType) throws BuildException {
Task task=createNewTask(taskType);
if(task!=null) {
addCreatedTask(taskType, task);
}
return task;
}

/**
* Creates a new instance of a task. This task is not
* cached in the createdTasks list.
* @since ant1.6
* @param taskType The name of the task to create an instance of.
* Must not be <code>null</code>.
*
* @return an instance of the specified task, or <code>null</code> if
* the task name is not recognised.
*
* @exception BuildException if the task name is recognised but task
* creation fails.
*/
private Task createNewTask(String taskType) throws BuildException {
Class c = (Class) taskClassDefinitions.get(taskType);

if (c == null) {
@@ -1125,7 +1147,6 @@ public class Project {

String msg = " +Task: " + taskType;
log (msg, MSG_DEBUG);
addCreatedTask(taskType, task);
return task;
} catch (Throwable t) {
String msg = "Could not create task of type: "


Loading…
Cancel
Save