Ah, I see, you are trying to
use the contents of "sources" in javc and also in bm:lsync.
This is indeed XML NS hell!
The problem is that the ns uri and local name of the Unknown elements
are given to the elements in the calling macro.
In ant 1.6.0+, the namespace of elements discovered by reflection take
the namespace uri of type/task that contains the element (Note this is the
uri and not the localname).
The enclosed patch will allow the namespace of nested elements to be
either the ant uri or the namespace of the containing type/task.
The following then works:
<project xmlns:bm="some uri or other">
<scripttypedef name="lsync" language="beanshell" uri="some uri or other">
import org.apache.tools.ant.taskdefs.MatchingTask;
public class LSync extends MatchingTask {
public void execute() {}
}
</scripttypedef>
<macrodef name="compile">
<element name="sources"/>
<sequential>
<javac destdir="classes" srcdir="src">
<sources/>
</javac>
<bm:lsync>
<sources/>
</bm:lsync>
</sequential>
</macrodef>
<compile>
<sources>
<include name="**/*.java"/>
</sources>
</compile>
</project>
Another solution would be to modify lsync to use the fileset type:
lsync -> void add(FileSet fs) { .. }
Then one can do:
<bm:lsync>
<bm:fileset dir="x"/> <!-- fileset is the nested addFileSet(Fileset fs) method
-->
<fileset dir="x"> <!-- fileset is the nested add(FileSet fs) using the
"fileset" type
in the ant core uri. -->
<include name="**/*.java"/>
</fileset>
</bm:lsync>
Peter
Dominique Devienne wrote:
From: Peter Reilly [mailto:[EMAIL PROTECTED]
As regards the xml ns hell, I must agree - I still think that nested
elements discovered through reflection should be in the ant core
namespace as well as the namespace of the enclosing type/task.
Well, I'm not following, but I'm not surprised, as my head hurts when I try
to think at the issues related to XML NS handling in Ant...
You are missing a bm prefix from a nested include of a fileset element in
a bm:lsync (i think) element.
Not really, and this is where I think I may have stumbled on a possible bug
or flow of the current design...
Going back to the macro definition, simplified:
<macrodef name="compile">
<element name="sources" /> <!-- <<< Declaration -->
<sequential>
<javac ...>
<sources/> <!-- <<< Use in Javac - default NS -->
</javac>
<bm:sync ...>
<fileset dir="src">
<sources/> <!-- <<< Use in lsync - BM NS -->
</fileset>
</bm:lsync>
</sequential>
</macrodef>
See how the macro element 'sources' is used in two different tasks, from two
different namespaces, the default/Ant NS, and my custom NS.
Apparently, it's currently impossible to use that same macro element in the
two places/tasks, when they are in different namespaces.
So is this a bug, design flaw, or user error???
And I can assure you all uses of the macro, as exemplified below, all have
the name attribute. This build has been working for weeks now, and I was
just trying to add the <sync> or <bm:lsync> additional step to it.
<compile name="dsp-test-utils">
<sources>
<include name="com/lgc/testing/junitplus/**"/>
<include name="com/lgc/testing/utils/**"/>
<none>
<contains text="import com.lgc.infra."/>
</none>
</sources>
</compile>
<compile name="dsp-util">
<sources>
<include name="com/lgc/java/**"/>
<include name="com/lgc/javax/**"/>
</sources>
</compile>
Also, is "sources" a typedef?
No, a macro element, as explained above. Please help. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: src/main/org/apache/tools/ant/IntrospectionHelper.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v
retrieving revision 1.77
diff -u -r1.77 IntrospectionHelper.java
--- src/main/org/apache/tools/ant/IntrospectionHelper.java 9 Feb 2004 21:05:16 -0000 1.77
+++ src/main/org/apache/tools/ant/IntrospectionHelper.java 24 Feb 2004 16:12:28 -0000
@@ -587,7 +587,7 @@
parentUri = "";
}
NestedCreator nc = null;
- if (uri.equals(parentUri)) { // || uri.equals("")) {
+ if (uri.equals(parentUri) || uri.equals("")) {
nc = (NestedCreator) nestedCreators.get(
name.toLowerCase(Locale.US));
}
@@ -728,7 +728,7 @@
return (
nestedCreators.containsKey(name.toLowerCase(Locale.US))
- && (uri.equals(parentUri))) // || uri.equals("")))
+ && ((uri.equals(parentUri)) || uri.equals("")))
|| DynamicConfigurator.class.isAssignableFrom(bean)
|| addTypeMethods.size() != 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]