| AW: Ant paths | AW: Ant paths 2005-05-04 - By Jan.Materne@(protected)
You should have a look at the manual. "Developing with Ant > Tasks using Properties, Filesets & Paths" [1] shows how to deal with <fileset>s and <path>s.
Jan
[1] http://ant.apache.org/manual/tutorial-tasks-filesets-properties.html
> -----Urspr?ngliche Nachricht----- > Von: Ben Gill [mailto:ben_d_gill@(protected)] > Gesendet am: Dienstag, 3. Mai 2005 20:49 > An: user@(protected) > Betreff: Ant paths > > Hi, > > The only reason I am even including Spring.jar - is because > Spring API > supports loading of files using the ant style **/*.xml > paths... (which is > really useful especially for my custom task..) > > But in theory, I should not need to include spring.jar for > this support - as > the logic to map these paths to File resoures must be in the > ant core API > somewhere... > > The question is, where are the classes that do this mapping > (between path + > file(s)), are they public, and do they have the interfaces I need? > > I currently call: > > org.springframework.core.io.support.PathMatchingResourcePatter > nResolver p = > new > org.springframework.core.io.support.PathMatchingResourcePatter > nResolver(); > > org.springframework.core.io.Resource[] resources = > p.getResources(antStylePath); > > if (resources != null) { > > info("Loaded [" + resources.length + "] > resources from > file"); > > for (int resourceNum=0; resourceNum < > resources.length; > resourceNum++) { > > org.springframework.core.io.Resource > resource = > resources[resourceNum]; > > String fileName = > resource.getFile().getAbsolutePath(); > debug("Processing file [" + fileName + "]"); > > Any help on this would be appreciated - it may save me having > to include the > 1.2MB spring.jar file with the distribution.. > > Ben > > I am sure there is probably a core Ant class I could use for > this support - > the code must be in there somewhere! > > But including spring works anyhow.. > > >From: Peter Reilly <peterreilly@(protected)> > >Reply-To: "Ant Users List" <user@(protected)> > >To: Ant Users List <user@(protected)> > >Subject: Re: Custom Ant Task with 3rd party library dependency > >Date: Tue, 03 May 2005 17:03:31 +0100 > >MIME-Version: 1.0 > >Received: from mail.apache.org ([209.237.227.199]) by > mc6-f39.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); > Tue, 3 May 2005 > 09:56:47 -0700 > >Received: (qmail 69893 invoked by uid 500); 3 May 2005 > 16:05:58 -0000 > >Received: (qmail 69868 invoked by uid 99); 3 May 2005 > 16:05:57 -0000 > >Received: neutral (hermes.apache.org: local policy) > >Received: from gate.corvil.net (HELO corvil.com) > (213.94.219.177) by > apache.org (qpsmtpd/0.28) with ESMTP; Tue, 03 May 2005 09:05:19 -0700 > >Received: from [172.18.1.171] (angel.local.corvil.com > [172.18.1.171])by > corvil.com (8.13.3/8.13.3) with ESMTP id j43G3JJi098748for > <user@(protected)>; Tue, 3 May 2005 17:03:19 +0100 > (IST)(envelope-from peterreilly@(protected)) > >X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8= > >Mailing-List: contact user-help@(protected); run by ezmlm > >Precedence: bulk > >List-Unsubscribe: <mailto:user-unsubscribe@(protected)> > >List-Subscribe: <mailto:user-subscribe@(protected)> > >List-Help: <mailto:user-help@(protected)> > >List-Post: <mailto:user@(protected)> > >List-Id: "Ant Users List" <user.ant.apache.org> > >Delivered-To: mailing list user@(protected) > >X-ASF-Spam-Status: No, hits=0.1 > required=10.0tests=FORGED_RCVD_HELO > >X-Spam-Check-By: apache.org > >User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) > >X-Accept-Language: en-us, en > >References: <BAY102-F37B431599546E7D535F241CC180@(protected)> > >X-Virus-Checked: Checked > >Return-Path: > user-return-50004-ben_d_gill=hotmail.com@(protected) > >X-OriginalArrivalTime: 03 May 2005 16:56:47.0216 (UTC) > FILETIME=[17AA6700:01C55001] > > > >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;rambiusparkisanius@(protected)&gt; > >>&gt;Reply-To: &quot;Ant Users List&quot; > >>&lt;user@(protected)&gt; > >>&gt;To: Ant Users List &lt;user@(protected)&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 > user-help@(protected); run by ezmlm > >>&gt;Precedence: bulk > >>&gt;List-Unsubscribe: > >>&lt;mailto:user-unsubscribe@(protected)&gt; > >>&gt;List-Subscribe: > &lt;mailto:user-subscribe@(protected)&gt; > >>&gt;List-Help: > &lt;mailto:user-help@(protected)&gt; > >>&gt;List-Post: &lt;mailto:user@(protected)&gt; > >>&gt;List-Id: &quot;Ant Users List&quot; > &lt;user.ant.apache.org&gt; > >>&gt;Delivered-To: mailing list user@(protected) > >>&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+rbXJDk0osXoEzXjRU ipoNSQW4NewMIiYwg/qaOtFAMDM6PMpORMjtGIkuIYAjaOUr73rgHa2PSma2ETrqsfojuM2s05Wt 8DJkgzb+FD8PZp8al/NSiI6zOh5VcQoajS1LnpTcEXA= > >> ; > >>&gt;X-Virus-Checked: Checked > >>&gt;Return-Path: > >>user-return-49999-ben_d_gill=hotmail.com@(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;ben_d_gill@(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/magazi > ne/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; user-unsubscribe@(protected) > >>&gt; &gt; For additional commands, e-mail: > >>&gt; &gt; user-help@(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: > user-unsubscribe@(protected) > >>&gt;For additional commands, e-mail: > user-help@(protected) > >>&gt; > >> > >> > >> > >>------------------------------------------------------ > --------------- > >>To unsubscribe, e-mail: user-unsubscribe@(protected) > >>For additional commands, e-mail: user-help@(protected) > >> > >> > >> > > > > > >---------------------------------------------------------- > ----------- > >To unsubscribe, e-mail: user-unsubscribe@(protected) > >For additional commands, e-mail: user-help@(protected) > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) >
|
|
 |