Malcolm,
You have fallen victim to the most common error when using functions... never nest your _expression_ evaluation brackets ${}
${directory::exists('${build.dir}')} becomes ${directory::exists(build.dir)}, and similar for your other expressions.
This is demonstrated in the fourth example o
this is your problem:
^^
don't quote variable names inside expressions - they will be treated as literal
strings. Use:
${directory::exists(build.dir)} instead.
The reason you're seeing mixed true and false output