简体   繁体   中英

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM