meridius
meridius

Reputation: 1587

Apache Ant property value with interperter

Why can't I set property like this in Apache Ant?

<property name="checker" value="php ${basedir}/vendor/code-checker/src/cc.php" />

And then exec it like this

<exec executable="${checker}">
    <arg value="-d" />
    <arg path="${basedir}/src" />
</exec>

Instead I have to specify whole path with that scripts' interpreter each time I want to use that checker

<exec executable="php">
    <arg value="vendor/code-checker/src/cc.php" />
    <arg value="-d" />
    <arg path="${basedir}/src" />
</exec>

Upvotes: 0

Views: 47

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122364

You can either use executable for the executable you want to run (php in this case) and arg for its arguments, or you can specify the command and all its arguments in a single space-separated attribute

<exec command="${checker} -d ${basedir}/src"/>

You can't mix and match the two. And note that the command form will not work if the basedir contains spaces. If there's any chance of an individual argument containing spaces then there's no choice, you must use the executable and arg form.

Upvotes: 1

Related Questions