In your resource you should not set the classpath. Doing so will
override the classpath given in the build file and cause ant to be confused.
So just use:
<antlib>
<taskdef name="renamepackages" classname="org.appfuse.ant.RenamePackages"/>
</antlib>



For example: src/testing/UseSpring.java: package testing; import org.springframework.beans.PropertyValue; import org.apache.tools.ant.Task;

public class UseSpring extends Task {
   private PropertyValue pv = new PropertyValue("hello", "world");
   public void execute() {
       log("pv is " + pv);
   }
}
src/testing/antlib.xml:
<antlib>
 <taskdef name="usespring" classname="testing.UseSpring"/>
</antlib>

build.xml:
<project name="testspring" default="use">
 <target name="jar">
   <mkdir dir="classes"/>
   <javac srcdir="src" destdir="classes" classpath="lib/spring.jar"/>
   <copy todir="classes">
     <fileset dir="src" includes="**/*.xml"/>
   </copy>
   <jar destfile="usespring.jar">
     <fileset dir="classes"/>
   </jar>
 </target>

<target name="use" depends="jar">
<typedef resource="testing/antlib.xml" classpath="usespring.jar:lib/spring.jar"/>
<usespring/>
</target>
</project>



Outputs: Searching for build.xml ... Buildfile: /home/preilly/learning/a/spring/build.xml

jar:
[mkdir] Created dir: /home/preilly/learning/a/spring/classes
[javac] Compiling 1 source file to /home/preilly/learning/a/spring/classes
[copy] Copying 1 file to /home/preilly/learning/a/spring/classes
[jar] Building jar: /home/preilly/learning/a/spring/usespring.jar


use:
[usespring] pv is PropertyValue: name='hello'; value=[world]

Peter

Ben Gill wrote:

Hi ,

Yes I have tried that (well a variety of this type of thing) and it is not working for me...

In my 'main' build.xml file I do this:

<typedef resource="org/appfuse/ant/appfuse-contrib.xml"
        classpath="spring.jar;rename-packages-1.0.jar"
        uri="appfuse:/org.appfuse.ant"/>

Then, in my appfuse-contrib.xml file I do:

<?xml version="1.0"?>
<antlib>

  <taskdef name="renamepackages"
           classname="org.appfuse.ant.RenamePackages"
           classpath="spring.jar"
           onerror="fail"/>

</antlib>

But whatever I try setting either classpath to (or even if I use inline classpath, or classpathref), my custom ant task cannot find the spring classes..

Is it possible what I am trying to do? Eric's article + other postings I have read seem to suggest, the only two ways of using 3rd party classes from wthin a custom task is to ether a) kick off a new JVM task or b) put the jars in the System classpath (ie. ANT_HOME/lib)..

Can anyone confirm either way??





&gt;From: Ivan Ivanov &lt;[EMAIL PROTECTED]&gt;
&gt;Reply-To: &quot;Ant Users List&quot; &lt;user@ant.apache.org&gt;
&gt;To: Ant Users List &lt;user@ant.apache.org&gt;
&gt;Subject: Re: Custom Ant Task with 3rd party library dependency
&gt;Date: Tue, 3 May 2005 07:01:41 -0700 (PDT)
&gt;MIME-Version: 1.0
&gt;Received: from mail.apache.org ([209.237.227.199]) by mc4-f41.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Tue, 3 May 2005 07:25:53 -0700
&gt;Received: (qmail 53754 invoked by uid 500); 3 May 2005 14:03:33 -0000
&gt;Received: (qmail 53741 invoked by uid 99); 3 May 2005 14:03:32 -0000
&gt;Received: pass (hermes.apache.org: local policy)
&gt;Received: from web52910.mail.yahoo.com (HELO web52910.mail.yahoo.com) (206.190.39.187) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 03 May 2005 07:03:32 -0700
&gt;Received: (qmail 92243 invoked by uid 60001); 3 May 2005 14:01:42 -0000
&gt;Received: from [212.95.183.130] by web52910.mail.yahoo.com via HTTP; Tue, 03 May 2005 07:01:41 PDT
&gt;X-Message-Info: JGTYoYF78jFXHutfHRffa3R5qXkgYW5muIU6wkBHhUc=
&gt;Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
&gt;Precedence: bulk
&gt;List-Unsubscribe: &lt;mailto:[EMAIL PROTECTED]&gt;
&gt;List-Subscribe: &lt;mailto:[EMAIL PROTECTED]&gt;
&gt;List-Help: &lt;mailto:[EMAIL PROTECTED]&gt;
&gt;List-Post: &lt;mailto:user@ant.apache.org&gt;
&gt;List-Id: &quot;Ant Users List&quot; &lt;user.ant.apache.org&gt;
&gt;Delivered-To: mailing list user@ant.apache.org
&gt;X-ASF-Spam-Status: No, hits=0.0 required=10.0tests=
&gt;X-Spam-Check-By: apache.org
&gt;Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
&gt;DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=hRifFK0n7F61CxssHDIcJp3K+/IJ98Ihh8+rbXJDk0osXoEzXjRUipoNSQW4NewMIiYwg/qaOtFAMDM6PMpORMjtGIkuIYAjaOUr73rgHa2PSma2ETrqsfojuM2s05Wt8DJkgzb+FD8PZp8al/NSiI6zOh5VcQoajS1LnpTcEXA= ;
&gt;X-Virus-Checked: Checked
&gt;Return-Path: [EMAIL PROTECTED]
&gt;X-OriginalArrivalTime: 03 May 2005 14:25:53.0590 (UTC) FILETIME=[0348B560:01C54FEC]
&gt;
&gt;Hello Ben,
&gt;
&gt;Have you tried with to &lt;taskdef&gt; your custom task with
&gt;classpath nested tag:
&gt;&lt;taskdef classname=&quot;org.myorg.MyTask&quot;&gt;
&gt; &lt;classpath&gt;
&gt; &lt;!-- location to your jars here --&gt;
&gt; &lt;/classpath&gt;
&gt;&lt;/taskdef&gt;
&gt;
&gt;HTH Ivan
&gt;--- Ben Gill &lt;[EMAIL PROTECTED]&gt; wrote:
&gt; &gt; Hi,
&gt; &gt;
&gt; &gt; My custom Ant task relies on the Spring jar files,
&gt; &gt; but whatever I try, I get
&gt; &gt; a class not found exception..
&gt; &gt;
&gt; &gt; I read a lot of posts on this and saw Eric's article
&gt; &gt; here:
&gt; &gt;
&gt; &gt;
&gt;http://www.fawcette.com/javapro/2003_02/magazine/features/ehatcher/
&gt; &gt;
&gt; &gt; But I cannot believe I have to spawn off a JVM to
&gt; &gt; pick up the spring jar's
&gt; &gt; do I?
&gt; &gt;
&gt; &gt; and I really dont want to force any user that uses
&gt; &gt; my task to copy the jar's
&gt; &gt; into their $ANT_HOME/lib...
&gt; &gt;
&gt; &gt; Has anyone got a nice, tidy way of making 3rd party
&gt; &gt; jar files available to a
&gt; &gt; custom task?
&gt; &gt;
&gt; &gt; Thanks
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt;---------------------------------------------------------------------
&gt; &gt; To unsubscribe, e-mail:
&gt; &gt; [EMAIL PROTECTED]
&gt; &gt; For additional commands, e-mail:
&gt; &gt; [EMAIL PROTECTED]
&gt; &gt;
&gt; &gt;
&gt;
&gt;
&gt;
&gt;__________________________________
&gt;Do you Yahoo!?
&gt;Yahoo! Small Business - Try our new resources site!
&gt;http://smallbusiness.yahoo.com/resources/
&gt;
&gt;---------------------------------------------------------------------
&gt;To unsubscribe, e-mail: [EMAIL PROTECTED]
&gt;For additional commands, e-mail: [EMAIL PROTECTED]
&gt;




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to