DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18613>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18613 setproject not called for all created objects Summary: setproject not called for all created objects Product: Ant Version: 1.6Alpha (nightly) Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Core AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] For an object to interact with ant, it needs to have an project object. This is implemented by ant calling setproject on the object soon after creating it. The current mechanism is not wide enough: 1) task objects that do not extend task that have a setProject method, the setProject method gets called after all the other sets, adds and creates are called (example the Condition task) 2) data objects created by project and by introspection helper need to extend ProjectComponent to have setProject called. As ProjectComponent is a class and not an interface this percludes extending other classes 3) custom mappers, selectors and filters do not set the project (or only if the object is a ProjectComponent) 4) general objects created by introspection helper do not set the object if the object does not extend ProjectComponent. I have made a patch that sets the project for these cases. The changes are: src/main/org/apache/tools/ant/Project.java * add a new static method setProjectOnObject(project, object) this checks to see if the object has a setProject(Project) method and if so calls it. * call setProjectOnObject when creating a task * call setProjectOnObject when creating a dataobject src/main/org/apache/tools/ant/ComponentHelper.java * call setProjectOnObject when creating a task * call setProjectOnObject when creating a dataobject src/main/org/apache/tools/ant/IntrospectionHelper.java * call setProjectOnObject instead of ProjectComponent#setProject() src/main/org/apache/tools/ant/Main.java * call set projectOnObject for listeners and inputhandlers src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java * call setProjectOnObject for filterreaders instead of ProjectComponent#setProject() src/main/org/apache/tools/ant/types/Mapper.java * call setProjectOnObject for created mapper objects src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java * call setProjectOnObject for created dynamic selector objects (see bugzilla: 18563) I have ran into this problem a number of times :- when adding custom conditions (bugzilla: 17199) and when adding tokenfilter (bugzilla: 18312). This patch superceeds their changes to TaskAdapter and UnknownElement.