Either I have found a bug with taskdef or I am botching the systax of
classpath elements.
I can define classpath as an attribute of taskdef, but I cannot define
classpath in a nested <classpath> tag.
Here is an example I built to illustrate this.
I make a class ant_test.SysOUtTask by copying the example MyVeryOwnTask
given in the docs.
The class is located at c:\AntTests\ant_test\SysOutTask.class and also
within the jar c:\AntTests\sysout.jar.
I place build.xml (text below) in c:\AntTests\run (not in c:\AntTests, since
present working directory is in the classpath for Ant anyway.)
I run ant.
I find that when classpath is defined as an attribute, Ant finds the class,
but when classpath is a nested element, I get
java.lang.ClassNotFoundException: ant_test.SysOutTask
at java.lang.Throwable.<init>(Throwable.java:96)
Replacing backslash with slash does not help.
Sincerely,
Joshua Fox
////////////////////////////////////////////////////////////////////////////
////////////////////////////////
Here is build.xml: Uncomment appropriately to test taskdefs. I have
indicated which taskdefs are OK and not OK.
<?xml version = "1.0" encoding = "UTF-8"?>
<project name="simple" default="do_all" basedir="c:/ant_test">
<!-- OK: -->
<taskdef name="sysout"
classname="ant_test.SysOutTask"
classpath="C:\AntTests"
>
</taskdef>
<!-- *************************************** -->
<!-- OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
classpath="C:\AntTests\sysout.jar"
>
</taskdef>
-->
<!-- *************************************** -->
<!-- Not OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
>
<classpath path="C:\AntTests" />
</taskdef>
-->
<!-- *************************************** -->
<!-- Not OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
>
<classpath>
<pathelement path="C:\AntTests\sysout.jar" />
</classpath>
</taskdef>
-->
<target name="do_all" />
</project>
<?xml version = "1.0" encoding = "UTF-8"?>
<project name="simple" default="do_all" basedir="c:/ant_test">
<!-- OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
classpath="C:\AntTests"
>
</taskdef>
-->
<!-- *************************************** -->
<!-- OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
classpath="C:\AntTests\sysout.jar"
>
</taskdef>
-->
<!-- *************************************** -->
<!-- Not OK: -->
<taskdef name="sysout"
classname="ant_test.SysOutTask"
>
<classpath path="C:\AntTests" />
</taskdef>
<!-- *************************************** -->
<!-- Not OK: -->
<!--
<taskdef name="sysout"
classname="ant_test.SysOutTask"
>
<classpath>
<pathelement path="C:\AntTests\sysout.jar" />
</classpath>
</taskdef>
-->
<target name="do_all" />
</project>