DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Base Directory Name And Path Manipulation In Apache Ant

09.04.2011
| 4696 views |
  • submit to reddit
        // The following will provide you an outline of basedirectory name and path in Apache Ant

<!--
    Author : Debadatta Mishra
    Description : This ant script provides the followings.
   
    1. Full path of the base directory.
    2. Root or parent path of the base directory.
    3. Only Directory name of the base diectory.
-->
<project name="basedirnametest" basedir="." default="test">

 <basename property=”basedir.name”     file=”${basedir}”/>
 <property name=”base.dir.name”        value=”${basedir.name}” /> 
 <dirname property=”antfile.dir”       file=”${basedir}”/> <!– Provides Root Path –>
 
    <target name=”test”>
        <echo>Base Directory Path : ${basedir}</echo>
     <echo>Base Directory Parent Path : ${antfile.dir}</echo>
     <echo>Base Directory only Name : ${base.dir.name}</echo>
    </target>

</project>