Set the ant property by invoking a shell script?

Is there a way to set the ant property by capturing shellscript output? (or other ant task)

Something like that:

<property name="foo"> <value> <exec executable="bar" /> </value> </property> 

Thanks!

+6
source share
3 answers

The exec task seems to have an outputproperty property, for example:

 <exec executable="bar" outputproperty="foo" /> 
+6
source

In ANT, the exec task

  • Set the output attribute: the name of the file in which the output will be written.
  • As Marble suggested - set outputproperty

When I tested, they were mutually exclusive. Therefore, install only 1 of them at a time.

+8
source

To extend the answer to @Nim, complex commands can be generated using arg tags:

 <exec executable="/usr/bin/git" outputproperty="git.branch"> <arg value="rev-parse"/> <arg value="--abbrev-ref"/> <arg value="HEAD"/> </exec> 

This can be referenced later, for example:

 <attribute name="Git-Branch" value="${git.branch}"/> 
+2
source

Source: https://habr.com/ru/post/925094/


All Articles