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.
The 'basedir' is the base directory from which any relative directories used within the Ant build file are referenced from. If this is omitted the parent directory of the build file will be used.
To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.
Ant uses an xml file for its configuration. The default file name is build. xml . Ant builds are based on three blocks: tasks, targets and extension points. A task is a unit of work which should be performed and constitutes of small atomic steps, for example compile source code or create Javadoc.
The whole Properties object returned by System.getProperties()
is exposed by Ant. Try this:
<echo>${user.dir}</echo>
${basedir}
might also be useful.
In Netbeans under Linux, ${user.dir}
seems always to equal ${user.home}
, but ${basedir}
gives me actual directory where ant is ran from (so it gives me the project dir).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With