Bug 25860 - Ant runner sets basedir incorrectly
Summary: Ant runner sets basedir incorrectly
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows NT
: P1 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords: core, ui
: 28802 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-11-07 15:58 EST by Matthew Conway CLA
Modified: 2003-01-14 21:33 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Conway CLA 2002-11-07 15:58:11 EST
Build id: 200211051258

The Ant runner sets the basedir property (${basedir} in ant scripts) to the
working directory and not the directory of the ant script like normal ant does.

i.e. for 'c:/foo/build/bar.xml' run with a working directory of 'c:/foo'
basedir should be 'c:/foo/build'
But instead it is being set to 'c:/foo'

This happens when using ant runner 'variables like so:
Location: ${workspace_loc:/foo/build/bar.xml}
Working Dir: ${workspace_loc:/foo}

I haven't tried it with absolute paths
Comment 1 Darin Swanson CLA 2002-11-26 20:51:21 EST
Maybe I am missing the obvious here but what would the meaning of setting the 
working directory be for an Ant build?
Comment 2 Matthew Conway CLA 2002-12-04 14:21:53 EST
I was only explicitly setting the working dir to illustrate the bug. If left
unset, the working dir defaults to some other value (I think it was the eclipse
working dir?), and basedir ended up being that value.

Also, as a workaround, I _had_ to set the working dir to the location of the
script for basedir to be set correctly.

You are correct in that that working dir should be irrelevant to running an ant
script, but the prescence of this bug was causing it to have an effect.

When I created this bug, basedir was not getting set correctly if I left the
working dir unset.  However, in build 200211151436, it seems that if I leave
working dir unset, basedir does get set correctly, but if I _do_ set working
dir, then basedir incorrectly gets set to that value (basedir should ALWAYS be
the location of the script).
Comment 3 Darin Swanson CLA 2002-12-04 14:27:29 EST
So as a user, working directory specification should not be allowed for an ant 
script?
Comment 4 Matthew Conway CLA 2002-12-04 14:36:59 EST
I'm not sure thats right either.  In CLI ant, you can have different values for
${basedir} and System.getProperty("user.dir") (via java script, or java code in
a custom task)

So, a user should probably be allowed to set the working dir for a script
execution, but doing so should not affect the value of basedir.
Comment 5 Darin Swanson CLA 2002-12-04 14:47:14 EST
Thanks for the explanation.

The unfortunate part of setting system properties is the currently Ant can only 
be run in the same VM as eclipse. Changing the user.dir could cause all sorts 
of problems.  
Maybe this can only be a feature when Ant can be run in a separate VM (bug 
24129)?

Comment 6 Matthew Conway CLA 2002-12-04 15:02:03 EST
Unfortunately it goes further than just the system property - java.io.File path
resolution uses the JVMs working directory for relative paths =(

I guess so long as basedir is always set correctly, there is not much need for
being able to change working directory for a script.  A well written script
should not be dependent on what directory it is run from anyway.

Originally, I wasn't so much concerned with setting the working directory, just
having a correct value for ${basedir}, as all paths in my scripts end up being
constructed relative to basedir.

If you aren't running ANT scripts in a new JVM, what effect does the working
directory field have?

Comment 7 Darin Swanson CLA 2002-12-04 15:10:30 EST
Currently setting the working directory sets the basedir.
Comment 8 Matthew Conway CLA 2002-12-04 16:11:10 EST
Ok, thats confusing, or at least inconsistent with the way ANT does things, and
should probably be changed.

${basedir} exists so that scripts don't have to rely on working directory, so
setting basedir to the value of the working directory seems wrong.  The field
should probably be removed untill you add a way to run an ant script in a new JVM.

Comment 9 Darin Swanson CLA 2002-12-14 11:19:35 EST
Likely should be done when reworking the launch configuration tabs to be ant 
specific and to handle launching in a separate VM.
Comment 10 Darin Swanson CLA 2003-01-01 14:48:12 EST
*** Bug 28802 has been marked as a duplicate of this bug. ***
Comment 11 Darin Swanson CLA 2003-01-14 11:58:44 EST
Our current plan is to rename the text field "Base Directory".
We have a set of users who are relying on the fact that they can set the base 
directory from the UI.
Comment 12 Darin Swanson CLA 2003-01-14 12:22:58 EST
Fixed in AntMainTab and ExternalToolsMainTab
Please verify (DarinW).
Comment 13 Darin Wright CLA 2003-01-14 21:33:03 EST
Verified.