You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ben Gill <be...@hotmail.com> on 2005/05/03 20:48:37 UTC
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.PathMatchingResourcePatternResolver p =
new
org.springframework.core.io.support.PathMatchingResourcePatternResolver();
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@apache.org>
>Reply-To: "Ant Users List" <user@ant.apache.org>
>To: Ant Users List <user@ant.apache.org>
>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@ant.apache.org>; Tue, 3 May 2005 17:03:19 +0100
(IST)(envelope-from peterreilly@apache.org)
>X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8=
>Mailing-List: contact user-help@ant.apache.org; run by ezmlm
>Precedence: bulk
>List-Unsubscribe: <mailto:user-unsubscribe@ant.apache.org>
>List-Subscribe: <mailto:user-subscribe@ant.apache.org>
>List-Help: <mailto:user-help@ant.apache.org>
>List-Post: <mailto:user@ant.apache.org>
>List-Id: "Ant Users List" <user.ant.apache.org>
>Delivered-To: mailing list user@ant.apache.org
>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@phx.gbl>
>X-Virus-Checked: Checked
>Return-Path: user-return-50004-ben_d_gill=hotmail.com@ant.apache.org
>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@yahoo.com&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 user-help@ant.apache.org; run by ezmlm
>>&gt;Precedence: bulk
>>&gt;List-Unsubscribe:
>>&lt;mailto:user-unsubscribe@ant.apache.org&gt;
>>&gt;List-Subscribe:
&lt;mailto:user-subscribe@ant.apache.org&gt;
>>&gt;List-Help: &lt;mailto:user-help@ant.apache.org&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:
>>user-return-49999-ben_d_gill=hotmail.com@ant.apache.org
>>&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@hotmail.com&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; user-unsubscribe@ant.apache.org
>>&gt; &gt; For additional commands, e-mail:
>>&gt; &gt; user-help@ant.apache.org
>>&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@ant.apache.org
>>&gt;For additional commands, e-mail: user-help@ant.apache.org
>>&gt;
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Ant paths
Posted by Ben Gill <be...@hotmail.com>.
Hi
Yes Jan sent me a link to an article about this - it is perfect for what I
need!!
Thanks
>From: Erik Hatcher <erik@ehatchersolutions.com>
>Reply-To: "Ant Users List" <user@ant.apache.org>
>To: "Ant Users List" <user@ant.apache.org>
>Subject: Re: Ant paths
>Date: Wed, 4 May 2005 07:05:14 -0400
>MIME-Version: 1.0 (Apple Message framework v728)
>Received: from mail.apache.org ([209.237.227.199]) by
mc10-f3.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 4 May 2005
04:06:43 -0700
>Received: (qmail 69630 invoked by uid 500); 4 May 2005 11:07:34 -0000
>Received: (qmail 69572 invoked by uid 99); 4 May 2005 11:07:33 -0000
>Received: pass (hermes.apache.org: local policy)
>Received: from Unknown (HELO ehatchersolutions.com) (69.55.225.129) by
apache.org (qpsmtpd/0.28) with ESMTP; Wed, 04 May 2005 04:07:33 -0700
>Received: by ehatchersolutions.com (Postfix, from userid 504)id
BAA4213E2006; Wed, 4 May 2005 07:05:29 -0400 (EDT)
>Received: from [192.168.1.101]
(va-chrvlle-cad1-bdgrp1-4b-b-169.chvlva.adelphia.net [68.169.41.169])by
ehatchersolutions.com (Postfix) with ESMTP id 8AE1F13E2005for
<user@ant.apache.org>; Wed, 4 May 2005 07:05:16 -0400 (EDT)
>X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8=
>Mailing-List: contact user-help@ant.apache.org; run by ezmlm
>Precedence: bulk
>List-Unsubscribe: <mailto:user-unsubscribe@ant.apache.org>
>List-Subscribe: <mailto:user-subscribe@ant.apache.org>
>List-Help: <mailto:user-help@ant.apache.org>
>List-Post: <mailto:user@ant.apache.org>
>List-Id: "Ant Users List" <user.ant.apache.org>
>Delivered-To: mailing list user@ant.apache.org
>X-ASF-Spam-Status: No, hits=0.0 required=10.0tests=
>X-Spam-Check-By: apache.org
>References: <BAY102-F27084D1D205632FC394B02CC180@phx.gbl>
>X-Mailer: Apple Mail (2.728)
>X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on javelina
>X-Spam-Status: No, score=-1.2 required=5.0
tests=AWL,BAYES_00,RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no
version=3.0.1
>X-Spam-Level:
>X-Virus-Checked: Checked
>Return-Path: user-return-50027-ben_d_gill=hotmail.com@ant.apache.org
>X-OriginalArrivalTime: 04 May 2005 11:06:43.0534 (UTC)
FILETIME=[5AE89EE0:01C55099]
>
>
>On May 3, 2005, at 2:48 PM, Ben Gill wrote:
>
>>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.PathMatchingResourcePatternResolve
>>r p =
>> new
>>org.springframework.core.io.support.PathMatchingResourcePatternResolve
>>r();
>>
>> 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..
>
>Have a look at Ant's Fileset and the way tasks use it with the
>DirectoryScanner (hopefully I'm not speaking of ancient API! :) -
>the facility to deal with patternsets (**/*.xml, for example) is
>built right in.
>
>Taking a look at some of Ant's tasks source code will be very
>helpful in this regard - such as the <copy> task.
>
> Erik
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Ant paths
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On May 3, 2005, at 2:48 PM, Ben Gill wrote:
> 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.PathMatchingResourcePatternResolve
> r p =
> new
> org.springframework.core.io.support.PathMatchingResourcePatternResolve
> r();
>
> 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..
Have a look at Ant's Fileset and the way tasks use it with the
DirectoryScanner (hopefully I'm not speaking of ancient API! :) - the
facility to deal with patternsets (**/*.xml, for example) is built
right in.
Taking a look at some of Ant's tasks source code will be very helpful
in this regard - such as the <copy> task.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org