Re: Is behavior of available task on empty file attribute as expected?
Stefan Bodewig <[email protected]> Thu, 13 Nov 2025 20:43:49 +0100
| Newsgroups | gmane.comp.jakarta.ant.user |
|---|---|
| Message-ID | <[email protected]> |
On 2025-11-13, Kottmann, Renzo (Finanzen) 443-1 wrote:
> My very first question after all the years using it (even before Maven came to life):
:-), welcome.
> Using Apache Ant(TM) version 1.10.15
> <!-- expected? An empty string should not lead to the statement the file would exist?!? -->
> <available file="" property="file.prop.empty" />
> <!-- gives: empty file.present=true -->
> <echo message="empty file.present=${file.prop.empty}" />
> <!-- expected -->
> <available file="${basedir}" property="file.exist" />
> <echo message="${basedir} present=${file.exist}" />
> Is this a bug or feature I do not know the reason for?
The file attribute is resolved relative to the projects basedir so
effectively "" becomes new File(${basedir}, "") and thus is the basedir
itself.
This is the reason why you see the result, it does not really answer
whether this is intentional. I've been around for a while and don't
recall we ever explicitly thought about what an empty string for a
file-typed attributed would mean.
Stefan