aspose file tools*
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
Author

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="${tomcat.dir.defined.in.build.properties}"/>

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 build.properties.

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
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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.

thanks,
bear
JavaRanch Sheriff


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

Joined: Dec 29, 2005
Posts: 308
If I set
absolute.path=C:/xxx/webapps

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'.

thanks.

[ 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: 16305
    
  21

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:

C:> SET TOMCAT_HOME=C:\JAKARTA\TOMCAT-5.0.30

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"/>


Customer surveys are for companies who didn't pay proper attention to begin with.
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 build.properties.

aaaargh...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting root path with Ant (on Windows)