File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes getting root path with Ant (on Windows) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "getting root path with Ant (on Windows)" Watch "getting root path with Ant (on Windows)" New topic

getting root path with Ant (on Windows)

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
hey folks.

My webapp-CM is (of course) done with Ant. How is it possible to signify in the copy-task that i am pointing to an absolute path (C:/xx/..../webapps).

e.g. <copy file"foo" todir="${}"/>

I tried a slash-prefix in todir="/${xxxx}" to get to root. Unfortunately on Windows Ant is putting always a C: to it, so todir is always fixed to current partition of harddisk. But my aim is to externalize the tomcat directory completely to my

Can that be done?

thank u!

aldana software engineering blog & .more
Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
Did not understanf wat u exactly wanna do... if its just the absolute path u need to mention, then the property should be assigned the absolute path of the folder where you want to copy.
Otherwise can you re-explain yuor problem?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

manuel and Pratik, JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

Please read this for more information.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
If I set

and put it to <copy todir="${absolute.path}" .../>,
Ant prepends ${basedir} to it, which is defined in <project>-tag.
I would like that 'todir' ignores 'basedir' and just takes 'absolute.path' as path.

writing todir="/${absolute.path}" does not work, because Ant on Windows still prepends C: to 'absolute.path'.


[ March 06, 2006: Message edited by: manuel aldana ]
[ March 06, 2006: Message edited by: manuel aldana ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

An absolute path has to include the drive ID. Else how how the apps know which of the 26 possible drives to search? Windows isn't like Unix where there's a single filesystem root.

However, I think this is what you're looking for:


For best results, set this in your Windows Control panel system environment, using whatever directory path locates the version of Tomcat you want to reference.

In your build.xml:

Now you can reference tomcat.home as needed. For example:

<property name="servlet.api.jar" value="${tomcat.home}/common/lib/servlet-api.jar"/>

An IDE is no substitute for an Intelligent Developer.
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
thank you (though i knew this already

i found my stupid error. i was using backslash \ as path seperator in my

I agree. Here's the link:
subject: getting root path with Ant (on Windows)
It's not a secret anymore!