Bug 26667 - External Tool variables are expanded in launch config dialog
Summary: External Tool variables are expanded in launch config dialog
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Darin Swanson CLA
QA Contact:
URL:
Whiteboard:
Keywords: ui
Depends on:
Blocks:
 
Reported: 2002-11-19 10:39 EST by Tomasz Stanczak CLA
Modified: 2003-01-15 17:42 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Stanczak CLA 2002-11-19 10:39:40 EST
in M2 it was possible to define the working directory of an external tool
like that:

${project_loc}\classes

Since I have lots of project, all with a \classes subdirectory, where all
the compiled *.class files end up, I could reach them all using one
external tool. The goal of the tool was to copy all the classes into an
location external to Eclipse.

Now Eclipse M3 doesn't like it, it also doesn't like ${project_loc} alone,
regardless if I put it into external tool working directory or arguments. The 
same applies to ${workspace_loc}. 

So it looks like one cannot use several Eclipse variables to parametrize 
external tools. Note: the Help file still describes ${project_loc} in context 
of external tools as a valid variable.
Comment 1 Darin Wright CLA 2002-11-28 11:23:11 EST
I am able to specify ${workspace_loc} in the latest code, but not 
${project_loc}.
Comment 2 Darin Swanson CLA 2002-12-14 11:21:42 EST
Address for M5
Comment 3 Jared Burns CLA 2003-01-14 15:03:48 EST
The ${project_loc} variable works just fine if you have a resource selected.
Without a selected resource, there's no context for determining which project
to use.
Comment 4 Jared Burns CLA 2003-01-14 16:36:41 EST
Looks like the problem here is that the launch config is trying to expand the variable even while the dialog is up. If you don't have a resource selected,
there's no context in which to expand the value of the project_loc variable.
Comment 5 Tomasz Stanczak CLA 2003-01-15 03:27:10 EST
Yes, that's what I also found out. 

instead of:

ExpandVariableContext.EMPTY_CONTEXT

(org.eclipse.ui.externaltools.launchConfigurations.ExternalToolsMainTab.java, 
method validateLocation, line 379 and method validateWorkDirectory line 411)

I used 

VariableContextManager.getDefault().getVariableContext()

and it has solved the problem.

But it brings up a general question: this dialog is a general preference, 
something you should be able to edit no matter where you are in the workbench. 
Using the current context in such a place feels ugly IMO. Wouldn't it be better 
to refrain from validating the variables and just let it go whatever I place 
there? I mean even if the dialog proves that all the variables fit the current 
context I can run it from a diffent context (a wrong one) and make it crash.

Another issue with variables is that it is disallowed to incorporate them 
within a string: see #29504.
   
Question aside: in a case like this one, is it better to create a separate 
cases for the two of them (like I did), or put it together, since they are very 
close to each other (I mean source code changes would have effects in the same 
place: external tools dialog and execution).
Comment 6 Jared Burns CLA 2003-01-15 09:06:01 EST
The fix I'm working on to this problem is to change the validation to only
check if the "tag" part of the variable (e.g. "project_loc") is valid. We won't
actually expand the value of the variable until the config is launched.
Comment 7 Tomasz Stanczak CLA 2003-01-15 09:33:19 EST
It would be extremely useful to be able to use Workbench|Path Variables as well.
Comment 8 Jared Burns CLA 2003-01-15 15:38:38 EST
Fixed. Please verify.
Comment 9 Darin Swanson CLA 2003-01-15 17:42:18 EST
Verified.