Phing, call a command get its output into a property

Josh Ribakoff picture Josh Ribakoff · Dec 3, 2009 · Viewed 7.1k times · Source

I have a script that can lookup and output or write my current release # to a text file. Now the only problem is how do I get this version number into a PHING property.

Right now my PHING target builds build.zip and built.tar, I would like it to build build-1.0.0.zip or whatever the version script decides the current version is. How can I do this? Will I have to create my own "task"?

Answer

Greg K picture Greg K · Apr 6, 2011

An alternative approach is to use the outputProperty attribute on the ExecTask to provide a property in your build file.

<target name="version">
  <exec command="cat version.txt" outputProperty="version.number" />
  <echo msg="Version: ${version.number}" />
</target>

More information