ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francesco Marchioni" <FMnotificati...@hotmail.com>
Subject Re: 2 Questions about building my own task
Date Wed, 30 May 2001 17:30:13 GMT
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>
>
>

Mime
View raw message