ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject My experience with namespaces in Ant 1.6 (WAS: RE: antlib: cannot find <fileset>?)
Date Wed, 14 Jan 2004 14:56:21 GMT
> From: Peter Reilly []
> >
> >     <lucene:index index="${index.base.dir}/index">
> >       <fileset dir="${files.dir}"/>
> This should be <lucene:fileset dir="${files.dir}"/>

2 remarks:

1) Using a namespace prefix on all nested elements can quickly become
   tedious for large tasks, with lots of nested elements. One way to
   remove the tedious is to change the default namespace for a given
   element and it's children:

   <index index="${index.base.dir}/index"
          xmlns ="antlib:org.apache.lucene.ant">
     <fileset dir="${files.dir}"/>

2) All task containers are exceptions to the rule that nested elements
   need to be in the same namespace than the task itself. For example:

        <ac:pathelement location="new-build.xml" />
        <ac:pathelement location="config/build2dependencies.xsl" />
        <ac:pathelement location="config/dependencies.xsd" />
        <ac:pathelement location="config/dependencies.xsl" />
        <ac:pathelement location="build/dependencies-ns.xml" />
        <ac:pathelement location="build/dependencies.xml" />
        <ac:pathelement location="build/dependencies.html" />
        <!-- Extract dependencies.xml from build.xml -->
        <style in="${ant.file}"
               processor="trax" />

        <!-- Post-process the XSL-generated file -->
        <bm:sed from="build/dependencies-ns.xml"

        <!-- Schema-validate the extracted dependencies.xml -->
        <bm:schemavalid file="build/dependencies.xml"
            externalNoNamespaceSchema="config/dependencies.xsd" />
        <echo message="build/dependencies.xml is schema-valid" />

        <!-- Generate dev-friendly HTML of dependencies.xml -->
        <style in="build/dependencies.xml"
               processor="trax" />

   See how Ant-Contrib's <outofdate> tasks nested elements must be
   in the Ant-Contrib namespace, but how the nested elements of the
   <sequential> belong to the Ant namespace, and another custom one.

   Other task with nested containers include <macrodef>, <if>, etc...

As a final note, I'd warn of a bug in Ant 1.6 (already fixed in CVS)
that prevents to declare the default namespace of the root <project>
element to be the Ant default namespace. The work around is simply
to not declare the root default namespace to the Ant namespace.

I hope this will help build writer going the namespace route. --DD

> It was decided in the 1.6.beta series that nested elements found by
> reflection on the task object should be in the same namespace
> as the task.
> Peter
> >     </lucene:index>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message