Jose Alberto Fernandez wrote:
I am all with you on the goal, my only point is that rather than
creating yet another way for mappers, we should do best by starting
working on 1.7's features so we try to converge to a unified model.
It would mean that mappers can be in their own antlib library,
use their owm NameSpace and all the other goodies of the model.
I believe that is the aim for 1.7 with the
add(Interface)
methods.
which are these?
This are new instrospection methods so that Conditions, mappers, etc
can be added and made available to all tasks automagically.
They are suppose to be part of 1.7.
This is want the patch does.
The patch makes the mapper class to be a container of
filenamemapper objects in the same way that conditionbase
is a container of conditions.
so:
<mapper type="glob" from="*.java" to="${destdir}/*.xml"/>
becomes:
<mapper>
<globmapper from="*.java" to="${destdir}/*.xml"/>
</mapper>
The two forms are allowed and are equivalent.
The second from allows more filename mappers to
be added so:
<mapper>
<globmapper from="*.java" to="${destdir}/*.xml"/>
<globmapper from="*.xml" to="${destdir}/*.meta.xml"/>
</mapper>
will map a/b/P.java to ${destdir}/a/b/P.xml
and a/b/P.xml to ${destdir}/a/b/P.meta.xml
The filenamemappers are found by using the add(FileNameMapper) method
in the mapper class so one can add new mappers easily.
<scripttypedef name="uppercasemapper" language="beanshell">
package my.mappers;
import org.apache.tools.ant.util.FileNameMapper;
public class upcasemapper implements FileNameMapper {
public void setFrom(String ignore) {}
public void setTo(String ignore) {}
public String[] mapFileName(String filename) {
return new String[] {filename.toUpperCase()};
}
}
</scripttypedef>
The filename mappers can be combined as a chain so that the output of the
first map is the input to the second map.
<mapper chain="yes">
<globmapper from="*.java" to="*"/>
<uppercasemapper/>
<globmapper from="*" to="${destdir}/*.xml"/>
</mapper>
would map a/b/P.java to ${destdir}/A/B/P.xml
Normal ant reflection is used on the filename mapper classes, so
the mapper classes may have extra attributes or nested elements.
For example the attribute "casesensitive" default yes could be added
to the globmapper:
<mapper>
<globmapper from="*.meta.java" to "${destdir}/*.xml" casesensitive="no"/>
</mapper>
would map a/b/t.META.java to ${destdir}/a/b/t.xml
This patch would be for ant 1.7 and not ant 1.6. It is expected that
during the construction of ant 1.7, roles or something similar would be
added to allow container specific nameing of typedef'ed nested elements.
In the meantime, the patch simply defines the current filename mappers as
normal global typedefs.
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]