Did just as for Node.js using full path to maven installation (that should be selected in Preferences). But it is weird that I needed to pass JAVA_HOME
and M2_HOME
, because otherwise I get JAVA_HOME not found
or M2_HOME not found
, just like when maven is not yet set up:
ERROR: M2_HOME not found in your environment.
Please set the M2_HOME variable in your environment to match the
location of the Maven installation
related code
public class LaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
@Override
public void launch(ILaunchConfiguration configuration, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
// skipped some argument processing
envp[idx++] = "JAVA_HOME=" + System.getProperty("java.home");
envp[idx++] = "M2_HOME=" + System.getenv("MAVEN_HOME");
String[] cmds = {};
cmds = cmdLine.toArray(cmds);
// Launch a process to run/debug. See also #71 (output is less or no output)
Process p = DebugPlugin.exec(cmds, workingPath, envp);
// no way to get private p.handle from java.lang.ProcessImpl
RuntimeProcess process = (RuntimeProcess)DebugPlugin.newProcess(launch, p, Constants.PROCESS_MESSAGE);
Is there some more beautiful way to do that? Please add as an answer.
UPDATE: This does not fully solves the problem, see Java - process launched with Runtime.getRuntime().exec( cannot create temp file