Bug 106803 - Ant launcher not setting working directory
diff --git a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java
index f520b61..626bbf8 100644
--- a/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java
+++ b/ant/org.eclipse.ant.tests.ui/Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java
@@ -200,7 +200,7 @@
//find the log file generated by the xml logger
getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- IFile iFile= getProject().getFile("log.xml");
+ IFile iFile= getProject().getFolder("buildfiles").getFile("log.xml");
assertTrue("Could not find log file named: log.xml" , iFile.exists());
File file= iFile.getLocation().toFile();
String content= getFileContentAsString(file);
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
index b6652c6..5ccf8df 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java
@@ -522,6 +522,7 @@
}
ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy();
+ setDefaultWorkingDirectory(copy);
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString());
StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome);
copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
@@ -724,4 +725,20 @@
}
return super.saveBeforeLaunch(configuration, mode, monitor);
}
+
+ /**
+ * Sets the default working directory to be the parent folder of the buildfile if
+ * the user has not explicitly set the working directory.
+ */
+ private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
+ try {
+ String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (wd == null) {
+ wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString();
+ copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
+ }
+ } catch (CoreException e) {
+ AntUIPlugin.log(e.getStatus());
+ }
+ }
}