Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting root path with Ant (on Windows)

 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Pratik Lohia
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you (though i knew this already

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

aaaargh...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic