ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angus McIntyre <an...@pobox.com>
Subject Re: FilenameMapper with multiple mappings?
Date Mon, 20 Jan 2003 16:05:34 GMT
At 8:59 +0100 20.01.2003, Stefan Bodewig wrote:
>On Sat, 18 Jan 2003, Angus McIntyre <angus@pobox.com> wrote:
>>  One would be to define a new FileNameMapper type, so as to be able
>>  to do something like:
>>
>>  	<mapper type="multiglob" from="*.xml,*.php"
>>  	to="*.html,*.php"/>
>
>Yes.  Maybe we should add some support for arbitrary nested elements
>in <mapper> (using DynamicElement?).

It occurred to me that to be able to do something like:

	<mapper type="multiple">
	   <mapper type="glob" from="*.xml" from="*.html"/>
	   <mapper type="glob" from="*.php" to="*.php"/>
	</mapper>

might be handy (possibly not with that exact syntax, but I'm sure you 
get the idea). It may be overkill, but someone would find a use for 
it sooner or later.

Also, am I correct in thinking that mappers are local to a task ... 
but their IDs are global?

What I've observed is that if I define a mapper with an 'id' 
attribute in one task, then I can use 'refid' to reference it within 
that same task, but if I try to reference it from elsewhere, I get 
errors telling me that I must specify at least type or classname 
(i.e. the mapper isn't identifiable/usable outside the task where it 
was defined). This seems reasonable enough, but if I define two 
mappers with the same ID in different tasks, I get warnings about 
non-unique IDs.

I think that if mappers become more complex, it would be good to be 
able to define them globally at the project level, and then reference 
them from within tasks. Unless I'm misunderstanding the way Ant 
works, this is not currently possible.

>>  looks to me as if I'd need to hack Mapper to make this work.
>
>No, just use the classname attribute instead of type.

Yes, I finally worked this out by myself ("Use the Force, Luke - read 
the source"), and hacked up my own mapper that takes comma-separated 
lists of extensions as 'from' and 'to' attributes. This works fine, 
and does just what I needed it to. Ant rocks, as they say.

Thanks

	Angus
-- 
angus@pobox.com                             http://pobox.com/~angus

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message