You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mads Andersen <ma...@pop.k-net.dk> on 2000/09/18 22:33:39 UTC

Ant can't find custom task

First of all, thanks for Ant! It's a great tool!

I'm having trouble getting Ant to find my own task. My build.xml begins
with:

---8<---
<project name="Madsie" default="dist" basedir=".">

  <taskdef name="transform"
classname="com.madsie.util.xsl.XSLTransformTask"/>

  <!-- set global properties for this build -->
  <property name="src" value="src" />
  <property name="build" value="build" />
  <property name="dist"  value="dist" />
---8<---

I then have defined a target later in build.xml:

---8<---
  <target name="collections">
    <transform/>
  </target>
---8<---

When I run Ant I get:

---8<---
C:\madsie\java>ant collections

Buildfile: build.xml

BUILD FAILED

build.xml:3: taskdef class com.madsie.util.xsl.XSLTransformTask cannot be
found

Total time: 1 seconds
---8<---

But the task is in the classpath as the following witness:

---8<---
C:\madsie\java>java com.madsie.util.xsl.XSLTransformTask
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
        at
com.madsie.util.xsl.XSLTransformTask.main(XSLTransformTask.java:148)
---8<---

XSLTransformTask extends MatchingTask so it should be of the right type etc.

Any ideas?

BTW: I'm aware of XSLTProcess, but it doesn't solve my particular XSLT
needs.

Best regards, Madsie


Re: Ant can't find custom task

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "MA" == Mads Andersen <ma...@pop.k-net.dk> writes:

 MA> I am using the latest nightly build,

This is what I called the CVS version - as opposed to Ant 1.1.

The latest is something relative. The nightly build that has been
available this morning (your and my morning) did not include the
changes, this is why I asked you to use the later version.

 MA> I just got it working!

Does that mean your problem went away?

Stefan

Re: Ant can't find custom task

Posted by Mads Andersen <ma...@pop.k-net.dk>.
> as you are obviously using the CVS version anyway, could you please
> try the latest version - must be the nightly build of 2000-09-19 which
> might not be available yet, or use CVS directly.

I am using the latest nightly build, and have never had ant installed
before. I just got it working! I had put the ant.jar in blabla/lib/ext, and
this apparently somehow affects the way the classloader maps qualified
classnames to the filesystem. Haven't really researched on why yet.

Best regards, Madsie


Re: Ant can't find custom task

Posted by Stefan Bodewig <bo...@bost.de>.
Mads,

as you are obviously using the CVS version anyway, could you please
try the latest version - must be the nightly build of 2000-09-19 which
might not be available yet, or use CVS directly.

I've commited some changes involving custom tasks yesterday and would
prefer to debug the new instead of an obsolete version 8^).

Stefan

Re: Ant can't find custom task

Posted by Mads Andersen <ma...@pop.k-net.dk>.
> If you run using the -verbose argument you should get a line which starts
> like this "Setting project property: java.class.path ->". Is your
> classpath correctly specified on this line?

Hmmm... there's something very odd about this whole thing. Suddenly Ant
couldn't find sun.tools.javac.Main, even though it was clearly in the
classpath. I copied tools.jar to the blabla\lib\ext directory (which is a
way to add jars without putting it in the classpath). Now that works.

What's the deal with this? Clearly something is odd about the whole search
for classes in Ant. My own introspection stuff works great, which the
following test shows:

public class Introspect {

    public static void main(String args[]) {
        try {
            Class clazz =
Class.forName("com.madsie.util.xsl.XSLTransformTask");

            System.out.println("Class " + clazz + " found.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Which works great (prints "Class class com.madsie.util.xsl.XSLTransformTask
found.").

I've attached the output from running with -verbose.

BTW: I'm using jdk1.3 under WinME.

Best regards, Madsie

Re: Ant can't find custom task

Posted by Nico Seessle <ni...@seessle.de>.
----- Original Message -----
From: "Mads Andersen" <ma...@pop.k-net.dk>
To: <an...@jakarta.apache.org>
Sent: Tuesday, September 19, 2000 12:23 AM
Subject: Re: Ant can't find custom task


> Now I've tried the very example in documentation (MyVeryOwnTask), and it
> still says:
>
> test.xml:4: taskdef class com.mydomain.MyVeryOwnTask cannot be found
>
> And the class is still found by simple "java com.mydomain.MyVeryOwnTask".
>
> This is driving me nuts!
>
> Best regards, Madsie
>

If you run using the -verbose argument you should get a line which starts
like this "Setting project property: java.class.path ->". Is your classpath
correctly specified on this line?

Nico



Re: Ant can't find custom task

Posted by Mads Andersen <ma...@pop.k-net.dk>.
Now I've tried the very example in documentation (MyVeryOwnTask), and it
still says:

test.xml:4: taskdef class com.mydomain.MyVeryOwnTask cannot be found

And the class is still found by simple "java com.mydomain.MyVeryOwnTask".

This is driving me nuts!

Best regards, Madsie