ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject <macro> and XML NS hell ;-)
Date Mon, 23 Feb 2004 22:33:29 GMT
OK, this is probably something stupid I'm doing. I'm using Ant 1.6.0.

Here's a macro, with a couple of its uses:

    <macrodef name="compile">
      <attribute name="name" />
      <element name="sources" />
      <element name="dependencies" />
      <sequential>
        <javac ...>
          <sources/>
          <classpath>
            <dependencies/>
          </classpath>
        </javac>
        <sync ...>
          <fileset dir="src">
            <sources/>
            <and>
              <or>
                <filename name="**/*.gif" />
                ...
              </or>
            </and>
          </fileset>
          <fileset dir="build/generated">
            <sources/>
            <and>
              <or>
                <filename name="**/*.ser" />
                ...
              </or>
            </and>
          </fileset>
        </sync>
      </sequential>
    </macrodef>

    <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>

      <dependencies>
        <path refid="dep-junit" />
        <path refid="dep-jfcunit" />
        <path refid="dep-jcfutils" />
      </dependencies>
    </compile>

    <compile name="dsp-util">
      <sources>
        <include name="com/lgc/org/**"/>
        <include name="com/lgc/jax/**"/>
        <include name="com/lgc/java/**"/>
        <include name="com/lgc/javax/**"/>
      </sources>
      <dependencies>
        <path refid="dep-junit" />
        <path refid="dep-vecmath"/>
        <pathelement location="build/classes/dsp-test-utils"/>
      </dependencies>
    </compile>

If I run as is, I get:

BUILD FAILED
java.lang.NullPointerException
        at java.lang.StringBuffer.<init>(StringBuffer.java:130)
        at
org.apache.tools.ant.types.PatternSet$NameEntry.toString(PatternSet.java:126
)
        at java.lang.String.valueOf(String.java:2131)
        at
java.util.AbstractCollection.toString(AbstractCollection.java:455)
        at java.util.Vector.toString(Vector.java:945)
        at java.lang.String.valueOf(String.java:2131)
        at java.lang.StringBuffer.append(StringBuffer.java:370)
        at
org.apache.tools.ant.types.PatternSet.toString(PatternSet.java:476)
        at java.lang.String.valueOf(String.java:2131)
        at java.lang.StringBuffer.append(StringBuffer.java:370)
        at
org.apache.tools.ant.types.AbstractFileSet.setupDirectoryScanner(AbstractFil
eSet.java:419
)
        at
org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileS
et.java:395)
        at org.apache.tools.ant.taskdefs.Copy.execute(Copy.java:423)
        at org.apache.tools.ant.taskdefs.Sync.execute(Sync.java:131)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:102)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:343)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:306)
        at org.apache.tools.ant.Task.perform(Task.java:401)
        at org.apache.tools.ant.Target.execute(Target.java:338)
        at org.apache.tools.ant.Target.performTasks(Target.java:365)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1237)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1094)
        at org.apache.tools.ant.Main.runBuild(Main.java:669)
        at org.apache.tools.ant.Main.startAnt(Main.java:220)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:215)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:90)

If I change the <sync> in the macro to my own <lsync>, found through a
namespace:

        <lsync xmlns="antlib:com.lgc.buildmagic" ...>
          <fileset dir="src">
            <sources/>
            <and>
              <or>
                <filename name="**/*.gif" />
                ...
              </or>
            </and>
          </fileset>
          <fileset dir="build/generated">
            <sources/>
            <and>
              <or>
                <filename name="**/*.ser" />
                ...
              </or>
            </and>
          </fileset>
        </sync>

I get:

BUILD FAILED
P:\com_lgc\10-0-7\tahoe\new-build.xml:501: Following error occured while
executing this line
P:\com_lgc\10-0-7\tahoe\new-build.xml:460: The <fileset> type doesn't
support the nested "antlib:com.lgc.buildmagic:sources" element.

And if I change that to (bm prefix mapped to antlib:com.lgc.buildmagic NS):

        <bm:lsync...>
          <bm:fileset dir="src">
            <sources/>
            <bm:and>
              <bm:or>
                <bm:filename name="**/*.gif" />
                ...
              </bm:or>
            </bm:and>
          </bm:fileset>
          <bm:fileset dir="build/generated">
            <sources/>
            <bm:and>
              <bm:or>
                <bm:filename name="**/*.ser" />
                ...
              </bm:or>
            </bm:and>
          </bm:fileset>
        </bm:sync>

I get:

BUILD FAILED
P:\com_lgc\10-0-7\tahoe\new-build.xml:500: Following error occured while
executing this line
P:\com_lgc\10-0-7\tahoe\new-build.xml:459: The <fileset> type doesn't
support the nested "include" element.

(BTW, the order I presented the various failures above is
reverse-chronological...)

So what's one to do!?!?!? I'm kind of stumped.

It would be helpful I think when an exception is thrown, like the NPE at the
beginning, to specify the same build file trace as the other errors, where
you know why build file line was executing when the exception was thrown.

Thanks for any help. --DD

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


Mime
View raw message