Find working directory from Ant

JW. picture JW. · Oct 20, 2009 · Viewed 43k times · Source

Is it possible to tell which directory the user ran Ant from?

For example, I might want to run only the unit tests in the current working directory, rather than all tests for the entire project.

I tried this:

<property environment="env" />
<echo>${env.CWD}</echo>

but that doesn't work.

Answer

Asaph picture Asaph · Oct 20, 2009

The whole Properties object returned by System.getProperties() is exposed by Ant. Try this:

<echo>${user.dir}</echo>