Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#60] Avoid deprecation warnings against newer JDT, support Java9 modules #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,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 @@ -139,22 +142,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 @@ -40,6 +40,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 @@ -152,7 +153,7 @@ public void launch(final ILaunchConfiguration configuration, final String mode,
MWEDebuggerLauncher launcher = new MWEDebuggerLauncher(vm);

// classpath
String[] classpath = getClasspath(configuration);
String[][] classpathAndModulepath = getClasspathAndModulepath(configuration);

// working dir
String workingDirName = null;
Expand Down Expand Up @@ -183,10 +184,32 @@ public void launch(final ILaunchConfiguration configuration, final String mode,
(String) null);

// bundle config
VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(wfRunnerClassName, classpath);
VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(wfRunnerClassName, classpathAndModulepath[0]);
runnerConfig.setWorkingDirectory(workingDirName);
runnerConfig.setProgramArguments(progArgs.toArray(new String[0]));
runnerConfig.setVMArguments(DebugPlugin.parseArguments(vmArgs));

if (!JavaRuntime.isModularConfiguration(configuration)) {
// Bootpath
runnerConfig.setBootClassPath(getBootpath(configuration));
} 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);
monitor.subTask("launching debugger ...");
Expand Down