Bug 25496 - [ExternalTools] leading slash when using path variables
Summary: [ExternalTools] leading slash when using path variables
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Ant-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
: 43413 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-29 11:27 EST by Bernhard Berbuir CLA
Modified: 2009-08-30 02:18 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Berbuir CLA 2002-10-29 11:27:17 EST
When using path variables like ${container_path} a leading slash ('/') is always
generated.
Example: /Thunderbird/Prod/de/sparkasseninformatik/thunderbird
Expected: Thunderbird/Prod/de/sparkasseninformatik/thunderbird (without leading
slash)

When using batch scripts, this is an ugly problem.
BTW: IntelliJs IDEA does not produce such slashes.
Comment 1 Bernhard Berbuir CLA 2002-10-31 05:41:32 EST
some more information:
The same happens with the variables $(project_path) and $(resource_path).
I'm using the default workspace within the Eclipse installation directory
(<Eclipse_inst_dir>\workspace) and the project uses the default location i.e.
<Eclipse_inst_dir>\workspace\Thunderbird (Thunderbird is the projectname)

BTW: why do the variables $(project_path), $(container_path) and
$(resource_path) generate slashes ('/) insted of backslashes ('\') at the
Windows platform ?
The variables $(workspace_loc), $(project_loc), $(container_loc) and
$(resource_loc) work fine.
Comment 2 Darin Wright CLA 2002-11-15 20:48:48 EST
Needs investigation
Comment 3 Darin Wright CLA 2003-01-29 13:26:06 EST
Jared, please see if these problems still exist with the variables re-work that 
you did.
Comment 4 Jared Burns CLA 2003-01-29 16:37:23 EST
The variables still behave as described. The paths that are output from the
path variables are in the platform independent format Eclipse uses for
workspace-relative paths.

I'm mildly hesitant to change this behavior because there could be users with
tools that depend on the paths to behave this way.
Comment 5 Jared Burns CLA 2003-01-29 17:05:29 EST
I've posted to the newsgroup asking if anyone is relying on the current format.
If there are no positive responses, my inclination is to change this as
requested.
Comment 6 John Arthorne CLA 2003-02-03 16:40:12 EST
Note that the eclipse platform distingues carefully between "paths" and
"locations".  Paths are always workspace or project relative, never have a
device, and always use forward slash.  Paths in this context describe where
resources are found in the workspace, regardless of their location on disk.

Locations always refer to places in the file system.  These are always absolute,
contain a device if applicable, and use the underlying OS path separator ('\' in
windows).

This is an important distinction, and they are not generally interchangeable. 
For example:

d:\eclipse -> eclipse install diretory
d:\foo -> location of project P1.
d:\foo\abc.txt -> File inside project P1.

The location of P1 is d:\foo, the workspace path of P1 is /P1.
The location of abc.txt is d:\foo\abc.txt, the path is /P1/abc.txt.

I suspect this is why the external tools have two different variables,
${resource_path) and $(resource_loc).  Unless you're using eclipse-specific ant
tasks, you probably just want the location, and don't care about the paths.
Comment 7 Jared Burns CLA 2003-02-03 17:02:00 EST
Right. But are Eclipse "paths" "/../text.txt" really useful outside Eclipse?

I don't think so. Outside Eclipse, slashes are generally platform dependent.
On *nix, for example, a leading forward slash is a device name equivalent to
"C:\" on Win32.
Comment 8 John Arthorne CLA 2003-02-03 17:34:38 EST
Right, most ant users (probably including Bernhard) are only interested in
"locations".  They can simply use resource_loc and project_loc instead of
resource_path and project_path.

If you're using Eclipse ant tasks, such as refresh local, you need to use
"paths".  There is also an Eclipse ant task (eclipse.convertPath) for converting
resource paths to locations, and vice-versa.

This probably just needs to be better documented.
Comment 9 Jared Burns CLA 2003-02-04 11:36:03 EST
Bernhard, can you use the *_loc variables or do you require workspace-relative,
OS-dependant paths? That is, what is your use case?
Comment 10 Bernhard Berbuir CLA 2003-02-04 12:11:34 EST
I'm using the parameters of the external Tool menu in some shell-scripts
(DOS-SHELL / cmd.exe). These scripts expects relative paths, which are DOS
conform. Therefor Unix-like paths or absolute paths are not usable.
Perhaps there should be an option in order to specify how these parameters are
resolved: Unix-style or DOS-style.
Comment 11 John Arthorne CLA 2003-02-04 12:55:37 EST
Bernhard, once again, these paths do not describe locations in the file system.
 They are a symbolic paths used to find resources in the workspace tree.  They
might not correspond to the paths of the resources in the file system.  If you
want relative paths, what do you expect them to be relative to?  The workspace
directory (the one specified by -data)?  The project location?  The current
working directory?  Can't the shell scripts handle the absolute paths supplied
by resource_loc and project_loc?
Comment 12 Bernhard Berbuir CLA 2003-02-05 05:47:31 EST
OK, perhaps I do not know enough about the special features of Eclipse /
advanced filesystems like symbolic links. I'm working with Windows NT 4.0, SP6a.
My workspace is hierarchically organized, i.e. all projects are located under
the workspace root (as specified with the -data option).
My script is executed in the folder of the workspace root. It concats an
"viewpath" (a path that point to a location in a SCM-System, defined by an
environment variable) with an relative path (provided by Eclipse). My current
workaround is to use a small C-program in order to reformat the relative path to
a valid DOS-Path.
Comment 13 John Arthorne CLA 2003-02-05 10:57:49 EST
If it's any help, the ${workspace_loc} parameter expands to the workspace
location.  If you remove ${workspace_loc}/ from the beginning of a
${resource_loc}, you'll get the path you're looking for.  I don't know if ant
has any string manipulation tasks that can help you do this.  In your case
${resource_path} happened to work because you stored all your projects in the
default location, but this won't be true in general if you have projects in
non-default locations or linked resources.
Comment 14 Jared Burns CLA 2003-02-05 11:16:38 EST
I don't think Ant ships with any string manipulation tasks, but they could be
out there as add-ons... or it would be easy to write them.

We *could* provide variables that would expand to workspace-relative, OS-valid
paths, but I'm hesitant to add too many variables that aren't generally
useful.

Bernhard, external tools makes it relatively simple to define your own
variables in a plug-in. If you're interested in this approach, take a look at
the variable definitions in the org.eclipse.ui.externaltools plugin.xml file
(Ctrl+F and search for resource_loc to jump to it). For the implementation
of a "variable expander", take a look at the class ResourceExpander. If
you're not concerned about API rules (which you're probably not if it's just
for your use), you can just subclass ResourceExpander and override the
getPath(...) method to return the path in the format you want.
Comment 15 Jared Burns CLA 2003-02-05 16:44:38 EST
We won't be making any code changes for this bug for 2.1.

Marking as LATER as we might want to add this to 2.2.
Comment 16 Darin Wright CLA 2003-09-23 17:03:56 EDT
*** Bug 43413 has been marked as a duplicate of this bug. ***
Comment 17 Darin Wright CLA 2004-07-22 10:24:26 EDT
*** Bug 43413 has been marked as a duplicate of this bug. ***
Comment 18 Denis Roy CLA 2009-08-30 02:18:50 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.