I have a build that needs a task for starting a process, and one for killing it at the end.
I have a file with the process id in it, but cannot figure out how to make ant expand the command substitution in order to pass the contents of that file to the kill command.
I have tried:
<target name="kill process">
<exec executable="kill">
<arg value="`cat process-file`"/>
</exec>
...
And:
<target name="kill process">
<exec executable="kill">
<arg value="$(cat process-file)"/>
</exec>
but both are converted to string litterals, and so result in:
[exec] kill: failed to parse argument: '$(cat process-file)'
Is there a way to make ant expand these? Or an altogether different route to accomplish this?
You can use Ant's loadfile
task to read the file's content into a property.
<loadfile srcFile="process-file" property="pid">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<exec executable="kill">
<arg value="${pid}"/>
</exec>
EDIT: added filterchain to deal with additional whitespace