Bug 3205 - Taskdef does not warn about task name clashes
Summary: Taskdef does not warn about task name clashes
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.4
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-08-21 09:07 UTC by Andreas Schildbach
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
here is a small demonstation project (1.09 KB, application/octet-stream)
2001-08-28 06:02 UTC, Andreas Schildbach
Details
Patch to Project.java for bug# 3205 (510 bytes, patch)
2001-09-23 23:05 UTC, Phil Hanna
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schildbach 2001-08-21 09:07:18 UTC
I tried to add a new task named "Get" via the file (property-style) mechanism. 
The Taskdef task did not tell me about the name clash with the existing built-
in task "Get". Instead, I learned at the invokation of the Task: "Class 
org.apache.tools.ant.taskdefs.Get doesn't support the "ref" attribute." (ref is 
a special attribute of my custom Get task)

I would suggest that Ant should warn about name clashes.
Comment 1 Conor MacNeill 2001-08-28 03:22:45 UTC
Can you send me a build file that gives this error. I think I know what is 
happening but I'd like to make sure.
Comment 2 Andreas Schildbach 2001-08-28 06:02:13 UTC
Created attachment 466 [details]
here is a small demonstation project
Comment 3 Phil Hanna 2001-09-23 23:05:21 UTC
Created attachment 596 [details]
Patch to Project.java for bug# 3205
Comment 4 Phil Hanna 2001-09-23 23:08:18 UTC
Attachment 596 [details] contains patch for this.  In the addTaskDefintion() method of 
Project.java, I check first for the existence of a task by that name in the 
taskClassDefinitions hashtable.  If it exists, I throw a BuildException.

The question remains, however, whether this is the desired behavior.  It makes 
it impossible to override tasks with others of the same name.  This could be 
made conditional on an "override" attribute on the <taskdef> element.
Comment 5 Conor MacNeill 2001-09-23 23:41:43 UTC
No this is not the desired behaviour. You should be able to override inbuilt 
tasks. A better fix may be to just always defer task creation by commenting out 
this line in ProjectHelper

                // task = project.createTask(tag);

That works OK but I haven't worked through any consequences yet.
Comment 6 Stefan Bodewig 2001-10-19 00:29:05 UTC
Nightly build 2001-10-20 will now at least print a warning, but it won't fix
Andreas original problem (the instance corresponding to <get> will be created
before the taskdef has been evaluated, so the old definition wins).

Workaround is to move the <taskdef> outside of a <target>.

Conor, your proposed patch would break the reference mechanism where
scripts or other tasks want to access task instances that have not been executed
yet.