You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Derek Slager <de...@activate.net> on 2002/03/04 06:16:10 UTC

[SUBMIT] Cat Task

Attached is a GNU gzipped tarball containing the sources, along with the
checklist items from http://jakarta.apache.org/ant/ant_task_guidelines.html.
I'm sure there are several things I've missed, as this is the first task
I've attempted to write. I tested the task on the following plaforms:

- Sun VM 1.3.0, Linux 2.4.3
- Sun VM 1.1.8, Linux 2.4.3

Justification:

 I had a need to use 'cat' in the context of an Ant build script, and was
 unable to find an existing task to suit my needs. There has also been at
 least one previous request for this feature, referenced at the below URL.

 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3540

Files:

 docs/manual/optionaltasklist.html.diff
 docs/manual/OptionalTasks/cat.html
 src/etc/testcases/taskdefs/optional/cat.xml
 src/main/org/apache/tools/ant/taskdefs/defaults.properties.diff
 src/main/org/apache/tools/ant/taskdefs/optional/Cat.java
 src/testcases/org/apache/tools/ant/taskdefs/optional/CatTest.java

Thanks,

-- 
Derek Slager
Software Engineer
Activate
derek@activate.net

Re: [SUBMIT] Cat Task

Posted by Stefan Bodewig <bo...@apache.org>.
On 02 Apr 2002, Stefan Bodewig <bo...@apache.org> wrote:

> Some notes:

some more

* addText() gets called for test1 on my machine - this is why I've added
sanitizeText().

* tearDown() would only delete the first file.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT] Cat Task

Posted by Stefan Bodewig <bo...@apache.org>.
Thanks Derek,

I'm going to commit the task - and make it a core task at the same
time.

Some notes:

* the task doesn't honor the user specified encoding if it is writing
to a file instead of Ant's logging system.

* shouldn't this snippet

        // If using filesets, disallow inline text. This is similar to
        // using GNU 'cat' with file arguments -- stdin is simply
        // ignored.
        if (fileSets.size() > 0) {
            throw new BuildException("Cannot include inline text " + 
                                     "when using filesets.");
        }

better be in execute than in addText?  The way it is right now, concat
will concatenate all files and fail after that, maybe even creating
the output file.

* we'll need to revisit the cleanup code at the end of execute().
Some similar code in the zip task family is know to cause problems in
some situations.

* Many thanks for providing a testcase!!

Cheers

        Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [SUBMIT] Cat Task

Posted by Derek Slager <de...@activate.net>.
On Thu, Mar 07, 2002 at 06:03:01PM +0100, Stefan Bodewig wrote:
> some comments:
> 
> (1) any problems with calling the task concat instead of cat?
> Non-Unix people will probably not recognize "cat".

It's not a problem for me -- changed.

> (2) Instead of tofile, I'd prefer destfile as an attribute name.

Not a problem -- changed. I did wonder about this one when initially putting
the task together -- the task design guidelines suggested 'destdir' as a
preferred name but made no mention of 'destfile'. I ended up choosing
'tofile', to be consistent with the Copy task.

> (3) You may consider using nested FileLists instead of/in addition to
> FileSets - the order by which DirctoryScanner returns the files is not
> determined while people using cat will probably need a specific order.

Yes, good idea. I didn't know what FileLists were until you mentioned them
(the documentation is a bit buried), but it seems quite reasonable to
include support for them. I believe that it's important to keep the FileSet
option as well, so they're both in there for now.

> (4) I'm not sure, but maybe an encoding attribute is needed.  We have
> gradually added encoding attributes to almost all tasks that read and
> modify files.

Yes, though it would only be used when dumping text to the console (the task
treats all file inputs as binary if the destination is a file). Of course,
we'd have to assume that all of the files being concatenated together have
the same encoding -- but I doubt that will ever become a serious issue. I've
added the support in any case.

Thank you for your comments. I apologize for the tardiness of my response --
things have been quite busy for me lately. The updated files are attached to
this message, contained within a GNU gzipped tarball.

 docs/manual/optionaltasklist.html.diff
 docs/manual/OptionalTasks/concat.html
 src/etc/testcases/taskdefs/optional/concat.xml
 src/main/org/apache/tools/ant/taskdefs/defaults.properties.diff
 src/main/org/apache/tools/ant/taskdefs/optional/Concat.java
 src/testcases/org/apache/tools/ant/taskdefs/optional/ConcatTest.java

Thanks again,

-- 
Derek Slager
Software Engineer
Activate
derek@activate.net

Re: [SUBMIT] Cat Task

Posted by Stefan Bodewig <bo...@apache.org>.
Derek,

some comments:

(1) any problems with calling the task concat instead of cat?
Non-Unix people will probably not recognize "cat".

(2) Instead of tofile, I'd prefer destfile as an attribute name.

(3) You may consider using nested FileLists instead of/in addition to
FileSets - the order by which DirctoryScanner returns the files is not
determined while people using cat will probably need a specific order.

(4) I'm not sure, but maybe an encoding attribute is needed.  We have
gradually added encoding attributes to almost all tasks that read and
modify files.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>