Skip to content

Commit

Permalink
Allow to debug w/ Java9++
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnekow committed Nov 29, 2019
1 parent cf59d61 commit 9eab0d6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
import java.io.IOException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.emf.mwe.core.WorkflowRunner;
import org.eclipse.emf.mwe.internal.core.debug.communication.Connection;
import org.eclipse.emf.mwe.internal.ui.debug.model.DebugTarget;
import org.eclipse.emf.mwe.internal.ui.workflow.Activator;
Expand Down Expand Up @@ -138,22 +141,33 @@ private String[] renderCommandLine(final VMRunnerConfiguration config, final int
}
}

// classpath
String[] cp = config.getClassPath();
if (cp.length > 0) {
arguments.add("-classpath");
StringBuilder cpSb = new StringBuilder();
for (String cpEntry : cp) {
cpSb.append(cpEntry);
cpSb.append(File.pathSeparator);
String[] mp = config.getModulepath();
if (mp != null && config.getModuleDescription() != null) {
if (mp.length > 0) {
arguments.add("-p");
arguments.add(Arrays.stream(mp).collect(Collectors.joining(File.pathSeparator)));
}
arguments.add(cpSb.substring(0, cpSb.lastIndexOf(File.pathSeparator)));
String mweModuleDescription = WorkflowRunner.class.getPackage().getName();
// maybe add --add-reads

arguments.add("--add-modules");
arguments.add(config.getModuleDescription());

arguments.add("-m");
arguments.add(mweModuleDescription + "/" + config.getClassToLaunch());

} else {
// classpath
String[] cp = config.getClassPath();
if (cp.length > 0) {
arguments.add("-classpath");
arguments.add(Arrays.stream(cp).collect(Collectors.joining(File.pathSeparator)));
}
// TODO: ER: make sure that all runtime classes that are provided by extensions (handlers, adapters) are in the class path
// the class to launch
arguments.add(config.getClassToLaunch());
}
// TODO: ER: make sure that all runtime classes that are provided by extensions (handlers, adapters) are in the class path

// the class to launch
arguments.add(config.getClassToLaunch());


// programArgs
String[] progArgs = config.getProgramArguments();
for (String element : progArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.emf.mwe.internal.ui.debug.model.DebugThread;
import org.eclipse.emf.mwe.internal.ui.workflow.Activator;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IModuleDescription;
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
Expand Down Expand Up @@ -193,6 +194,20 @@ public void launch(final ILaunchConfiguration configuration, final String mode,
} else {
// module path
runnerConfig.setModulepath(classpathAndModulepath[1]);
try {
// We do need the current project module later on - write it into the module description
IJavaProject proj = JavaRuntime.getJavaProject(configuration);
if (proj != null) {
IModuleDescription module = proj.getModuleDescription();
String modName = module == null ? null : module.getElementName();
if (modName != null) {
runnerConfig.setModuleDescription(modName);
}
}
}
catch (CoreException e) {
// Not a java Project so no need to set module description
}
}

monitor.worked(1);
Expand Down

0 comments on commit 9eab0d6

Please sign in to comment.