ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <jvan...@periapt.com>
Subject Re: Defining classpath with Taskdef
Date Thu, 30 Nov 2000 16:28:58 GMT
Hi Stefan,

I am defining the classpath as you suggested, and this still
doesn't work. Below are the simplest of build files, and
the simplest of tasks and the Taskdef just will not get
loaded. From the output of the debug log it doesn't
look like an attempt is even made to setup
the classpath. If this is known to work, then I'm
doing something really wrong. Everything works fine
as long as I build the classpath in a .bat|.sh script
before running Ant, but that's what I'm trying to
avoid.

-- LOG --

Ant version 1.2 compiled on October 24 2000

Buildfile: build-turbine.xml

...

Setting ro project property: ant.file ->
/home/jvanzyl/js/turbine/build/build-simple.xml
Project base dir set to: /home/jvanzyl/js/turbine/build
   +Task: taskdef

BUILD FAILED

/home/jvanzyl/js/turbine/build/build-simple.xml:3: taskdef class
org.apache.turbine.torque.ant.Si$
java.lang.ClassNotFoundException: org.apache.turbine.torque.ant.SimpleTask
...

-- BUILD FILE --

<project name="Torque" default="main" basedir=".">

  <taskdef name="simple" classname="org.apache.turbine.torque.ant.SimpleTask">
    <classpath>
      <fileset dir="../bin">
        <include name="*.jar"/>
      </fileset>
      <fileset dir="../lib">
        <include name="*.jar"/>
      </fileset>
    </classpath>
  </taskdef>

  <target name="main">
    <simple data="simple"/>
  </target>

</project>

-- TASK

package org.apache.turbine.torque.ant;

import org.apache.tools.ant.*;

public class SimpleTask extends Task
{
    private String data;

    public String getData() { return data; }
    public void setData(String v) { data = v; }
    public void execute() throws BuildException {
    System.out.println(data); }
}



On 30 Nov 2000, Stefan Bodewig wrote:

> <jvanzyl@periapt.com> wrote:
> 
> > Hi,
> > 
> > If I <echo> out the ${cp} property it is correct and
> > lists all the jar files that are required. In the snippet
> > listed below there are two ways of defining the classpath.
> 
> If you are calling the taskdef by means of <ant> and your <path> is
> part of the calling project you'll need to "tunnel" it through the
> property, so the refid version is not supposed to work. 
> 
> Otherwise, both ways should work as well as
> 
> <taskdef name="vtorque" classname="org.apache.turbine.torque.ant.VTorqueTask">
>   <classpath> 
>     <fileset dir="../bin">
>       <include name="*.jar"/>
>     </fileset>
>     <fileset dir="../lib">
>       <include name="*.jar"/>
>     </fileset>
>   </classpath>
> </taskdef>
> 
> You know that a <taskdef> performed in the called project won't have
> any effect on the calling project, right?
> 
> > I have tried both methods individually and still get
> > ClassNotFoundExceptions.
> 
> Where do you get the Exception? Inside the taskdef or when you try to
> use the task?
> 
> I'd suggest to use "ant -debug", this will list where Ant tries to
> load a class from, some classes must be loaded via the system
> classloader (using your system CLASSPATH), others will be loaded by
> Ant. You cannot load any class from a package starting with java. from
> your custom CLASSPATH for example.
> 
> Stefan
> 


Mime
View raw message