Ant – how to get current directory in Ant

how to get current directory in Ant ?

To get the current directory, you can directly use ant build-in property ${basedir}, it  gives us the actual directory where ant is ran from (also the parent directory of the buildfile).

<target name="print-directory">
  <echo>current directory: ${basedir}</echo>
</target>

how to get user working directory in Ant ?

To get the user working directory, you can directly use ant build-in property ${user.dir}, it is actually exposed by Java System.getProperties(). so it’s the JVM current working directory. it is for often located C:\Users\user_name.

<target name="print-directory">
  <echo>current directory: ${user.dir}</echo>
</target>

Оцените статью
ASJAVA.COM
Добавить комментарий

Your email address will not be published. Required fields are marked *

*

code