ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laramie Crocker <laramie_...@yahoo.com>
Subject stdout/result from java to ant
Date Thu, 26 Apr 2001 20:39:54 GMT
Hi,

Thanks for the help on this!
I considered the properties file solution, and that is
possibly what I'll use.  

However, I'm thinking this won't be the last time I
want something extra from an external entity to be
pumped into Ant.  I tend to write everything in Java,
(or Tcl or bash if absolutely necessary).  So the idea
of being able to write a java extension that
communicates results back to Ant will always be a tool
I'd reach for.  You said "short of writing an
extension..."  If I do write an extension, how do I
get stuff back to Ant.  All the methods seem to be
events, i.e., return void, and stdout is not trapped,
except to a file, and there are property setters, but
not getters from the Ant side.

Ideas?

Thanks again,
Laramie

--- Stefan Bodewig <bodewig@apache.org> wrote:
> Laramie Crocker <laramie_crocker@yahoo.com> wrote:
> 
> > Does anyone know how to get stdout from a task
(either exec or an
> > extension of org.apache.tools.ant.Task) such that
I can set a
> > property with the output?
> 
> Short of writing your onw task? Don't think so.
> 
> The easiest way probably is to make the task write
the output to a
> file (exec has an out attribute for this) and then
write a simple task
> that reads this file and sets a property from it.

If you're not into writing a task to do it, you could
do something like:
<target name="setprop">
  <exec executable="echo" output="today.properties">
    <arg value="-n"/>
    <arg value="today="/>
  </exec>
  <exec executable="sh">
    <arg line="-c " date +%A >> today.properties ""/>
  </exec>
</target>

then just read today.properties in with the regular
<property file=...>

Diane

=====
(holtdl@yahoo.com)





__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Mime
View raw message