Bug 57719 - Mapper classes should be loaded with ComponentHelper
Summary: Mapper classes should be loaded with ComponentHelper
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.9.4
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2015-03-17 09:27 UTC by Chuchi
Modified: 2015-04-19 04:59 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Chuchi 2015-03-17 09:27:51 UTC
All tasks are loaded with ComponentHelper but Mapper doesn't. In our environment we hack some classpath (and more things) when load the tasks but the mapper task is not loaded by the componente helper, the Tasks are creating the object (Copy task, MappingSelector, MappedResourceCollection, etc)
Comment 1 Stefan Bodewig 2015-04-19 04:59:17 UTC
This applies to all nested elements of tasks that are using the createXYZ() method rather than the addXYZ() variant.  This means in order to change this we'd need to modify all Ant tasks using create(), which is certainly possible for Ant's own tasks but not for third party tasks.

The "create" variant is there so that tasks can have full control over the classloader they use.  I don't think this applies to the Mapper case so it may be possible to replace create with add - but that would be breaking API backwards compatibility.

Are you using the <mapper class="xxxx"/> way of specifying the mapper?  If your class implements FileNameMapper you should be able to typedef it and add it to copy directly (since it also contains an add method for FileNameMapper) and use the core loader.  This would also work for all other tasks supporting mappers since <mapper> itself has an add method for FileNameMapper.

So rather than

  <mapper classname="foo.bar.Mapper"/>

you'd use

<typedef name="mymapper" classname="foo.bar.Mapper"/>


<typedef name="mymapper" classname="foo.bar.Mapper"/>

and should be able to control the classloader used for the typedef.