ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry V. Streepy, Jr." <stre...@healthlanguage.com>
Subject Re: 2 Questions about building my own task
Date Wed, 30 May 2001 18:49:24 GMT
You should hang on to the FileSet object reference that is passed in to
addFileset and only do the scan in your execute() method.  My assumption
is that the FileSet object is not fully initialized at the time the
addFileset method is called.

Move the code you show below into your execute method and things should
work correctly.

Francesco Marchioni wrote:
> 
> Hi again,
> I'm almost close to the solution.....I need a last help.....
> I made addFileset public() so it's correctly recalled, just it's missing the
> link from build.xml and the Task: in other words:
> 
> private FileSet set;
> 
> public void addFileset(FileSet set) {
> 
>         Project p = getProject();
>         DirectoryScanner ds = set.getDirectoryScanner(p);
>        String[] files = set.getDirectoryScanner(p).getIncludedFiles();
> }
> 
> ant complains that the basedir is not set!
> if  on the other hand  I do:
> 
> set.setDir("C:\mydir");
> DirectoryScanner ds = set.getDirectoryScanner(p);
> 
> then ant is able to create a DirectoryScanner and display files.......but
> obviously I want to set this
> from build.xml and not hardcode in my Task.
> 
> Still anybody on ?
> Regards,
> Francesco
> 
> ----- Original Message -----
> From: James Bucanek <subscriber@gloaming.com>
> To: <ant-user@jakarta.apache.org>
> Sent: Wednesday, May 30, 2001 6:11 PM
> Subject: Re: 2 Questions about building my own task
> 
> > At 5:49 PM +0200 5/30/01, Francesco Marchioni wrote:
> > >Hi Conor,
> > >thank you very much for your advice.
> > >As you suggest I have inserted a method  "void addFileset(FileSet set)"
> > >in my own task. It compiles correctly.
> > >
> > >Unfortunately I haven't been able to insert a fileset definition
> > >into my task "area". I get various parsing errors...please could you tell
> me
> > >where to
> > >insert a basic
> > >
> > ><fileset dir="${client.src}" >
> > ></fileset>
> > >
> > >...into
> > >
> > ><?xml version="1.0"?>
> > ><project name="OwnTaskExample" default="main" basedir=".">
> > >   <taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/>
> > >
> > >   <target name="main">
> > >     <mytask message="Hello World! MyVeryOwnTask works!"/>
> > >   </target>
> > >
> > ></project>
> > >
> >
> > Francesco,
> >
> > Since your task's tag is using a message="Hello..." attribute, I
> > assume you also have a corresponding setter method:
> >
> >      class MyVeryOwnTask extend Task
> >      ...
> >
> >          public void setMessage( String message )
> >          ...
> >
> >
> > Also, in your previous example you said you defined a
> >
> >      void addFileset( FileSet set )
> >
> > Remember that all of these methods are accessed via reflection, and
> > must be public or they won't be accessible to ant:
> >
> >      public void addFileset( FileSet set )
> >
> >
> > Hope that helps,
> >
> > James
> >
> >
> > __________________________________
> > James Bucanek
> > <mailto:privatereply@gloaming.com>
> >
> >

-- 
Larry V. Streepy, Jr.
Chief Technical Officer and VP of Engineering

Health Language, Inc.  -- "We speak the language of healthcare"
A subsidiary of CyberPlus Corp.

970/626-5028 (office)           mailto:streepy@healthlanguage.com
970/626-4425 (fax)              http://www.healthlanguage.com

Mime
View raw message