Ant pipes?

A while ago Duncan published a Blog entry quoting somebody saying that in Ant we’d forgotten some old Unix lessons such as the stringing together of simple filter operations in pipes. I can’t find the entry now since Duncan has rebuilt his blog on a new server. At the time I had a quick think about it and was not sure how we could provide the concept of a pipe in Ant. I didn’t get very far and let it go. Nevertheless, that thought has been jangling around in my head since then.

I recently saw a bug report in Ant about sorting the output of <echoproperties>. The normal approach would be to bung in a new attribute to control sorting of the output and just do that. But that does not make the functionality available to other Ant tasks. The idea of a pipe appealed

So, I wonder if a pipe could be created, something like this

<pipe>
  <echoproperties/>
  <sort/>
</pipe>

The pipe would route the log output of one task to an input method on the subsequent task for additional processing. Anyway, I’m at something of a low ebb right now and not in the mood to code so I thought I’d throw these thoughts out there for some feedback.

5 Replies to “Ant pipes?”

  1. I have long felt the need for <filterwriter> that is something similar to <filterreader> but works on the output stream/writer rather than the input stream. I haven’t yet found the energy to code it though. The way I had conceptualized it was:

    <echoproperties>
      <filterwriter>
        <sort ascending=”true”/>
        <head lines=”10″/>
      </filterwriter>
    </echoproperties>

    …placing the onus on the task to support <filterwriter>s.

    Chaining _tasks_ instead of <filterwriter>s seems to be a nice idea. Some hurdles to consider:

    If I want to <concat> a fileset into a dest file and transform the output in some way (say, sort) before writing into the dest file, I expect the task to work on the file output stream and not the stdout.

    I suppose tasks that write to stdout can benefit from <pipe>, and I guess there are use-cases for <filterwriter>s as well.

    What do you think?

  2. On Bugzilla 18976 someone asked for that and I had the same idea. But I had a problem with the redirector and didn´t get any response to my question on Ant-User.

    Anyway – I will read the two links provided by Stefan 🙂

Comments are closed.