Bug 72755 - Java Application and JUnit launch configurations should have the ability to set the default working directory
Summary: Java Application and JUnit launch configurations should have the ability to s...
Status: RESOLVED DUPLICATE of bug 41353
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-26 22:59 EDT by Joshua Benuck CLA
Modified: 2004-08-30 12:32 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 Joshua Benuck CLA 2004-08-26 22:59:04 EDT
When a new launch configuration is created for a Java Application or JUnit run
the default value that is filled in for the "Working directory" text field on
the Arguments tab is the project root.

I would like to see if it would be possible to add a "default working directory"
setting somewhere in the Java Project's properties (perhaps on the Java Build
Path pane either above or below the Default output folder) so you can specify
the default working directory for the project that should be used when a default
launch configuration is generated. (I'm requesting this on the project's
properties because each project may need a different default working directory
and it would be nice not to have to go in and modify the generated launch
configuration every time I run a new application or JUnit test suite for the
first time).

Please note that this "default working working directory" differs from the
checkbox on the arguments tab with the same name since that checkbox uses the
current process's working directory. (BTW, it would be far less confusing if
that checkbox was labeled "current process's working directory". It took me far
too long to figure out that the "default working directory" was really the
working directory of the current running process and not a settable default as I
had hoped. Should I write up a separate bug for this request?).

Thanks!
Comment 1 Joshua Benuck CLA 2004-08-27 11:44:40 EDT
I've also been looking for a way to specify the VM arguments on a per project
basis, but have not been able to find one.

This leads me to a modification of my request: instead of adding the default
working directory option to the Java Build Path pane in the Java Project's
properties dialog, why not add an additional pane that allows you to set both
the default VM arguments and the default working directory for the project?
Comment 2 Dirk Baeumer CLA 2004-08-30 06:58:52 EDT
This works for me in 3.0. The directory can be specified on the Arguments tab.
Comment 3 Joshua Benuck CLA 2004-08-30 11:19:25 EDT
I don't think I gave enough detail for you to see what I am talking about. I
apologize for that. Here are some steps to duplicate this issue:

- Create a new Java Project by using the "Create a Java Project wizard" using
the following settings:
         * Project name: example
         * Select the "create separate source and output folders" option
- Create a folder in the project called "cm"
- In the cm folder create a file called "test"
- In the src folder add a new class called Test.
- Have the class extend TestCase
- Choose the quick fix that adds the JUnit libraries
- Choose the quick fix that imports the TestCase class from junit.framework
- Add a method called testSomething that looks like this:
public void testSomething() throws Exception {
    assertTrue(new File("test").exists());
}
- Organize the imports to import java.io.File;
- From the Run menu choose Run As -> JUnit Test
- The test fails

Before running this test a launch configuration for class Test did not exist.
After running it a launch configuration does exist. When you open that
configuration you'll see that the "Use default working directory" has been set
on the arguments tab for this class with a default of ${workspace_loc:example}.

If you uncheck "Use default working directory" and change it to read
"${workspace_loc:example/cm}" and then rerun the test it passes.

When you have a few unit test classes this isn't much of an issue, but when you
have hundreds of tests spread across many different packages it gets to be quite
tedious to have to modify every launch configuration after first running the
test and having them fail because you are in the wrong working directory.

I usually also have to modify the launch configuration to add a VM parameter
because quite a few of our unit tests rely on a dll being in the library path.

What I want to be able to do is specify the default working directory and some
default VM parameters on a project level instead of having to modify this launch
configuration after it is created as I did above.

I hope this clarifies what I am requesting.
Comment 4 Dirk Baeumer CLA 2004-08-30 12:27:40 EDT
Sorry, didn't fully read the request ;-).

IMO adding this to the class path is the wrong thing to do (what if two 
configs in the same project need different settings). For me this sounds more 
like a launch configuration template.

Moving to Debug for comments.
Comment 5 Darin Wright CLA 2004-08-30 12:32:25 EDT
Yes, this would be acheived with templates.

*** This bug has been marked as a duplicate of 41353 ***