From 0695ed1416b93165997692fe7b50bfc4649f942e Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Tue, 10 Sep 2002 20:17:25 +0000 Subject: [PATCH] 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 --- src/main/org/apache/tools/ant/Project.java | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index aa5e6f7a3..126ca44bf 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -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 null. * @@ -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 null. + * + * @return an instance of the specified task, or null 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: "