diff --git a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java index 12b1ddde5..be37285e3 100644 --- a/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java +++ b/com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java @@ -182,7 +182,7 @@ private static String[][] computeClassPath(String mainClass, String projectName) IJavaElement testElement = findMainClassInTestFolders(project, mainClass); List mappedResources = (testElement != null && testElement.getResource() != null) ? Arrays.asList(testElement.getResource()) : Collections.EMPTY_LIST; - return computeClassPath(project, testElement == null, mappedResources); + return computeClassPath(project, mainClass, testElement == null, mappedResources); } /** @@ -195,13 +195,13 @@ private static String[][] computeClassPath(String mainClass, String projectName) * @throws CoreException * CoreException */ - private static String[][] computeClassPath(IJavaProject javaProject, boolean excludeTestCode, List mappedResources) + private static String[][] computeClassPath(IJavaProject javaProject, String mainType, boolean excludeTestCode, List mappedResources) throws CoreException { if (javaProject == null) { throw new IllegalArgumentException("javaProject is null"); } - ILaunchConfiguration launchConfig = new JavaApplicationLaunchConfiguration(javaProject.getProject(), excludeTestCode, mappedResources); + ILaunchConfiguration launchConfig = new JavaApplicationLaunchConfiguration(javaProject.getProject(), mainType, excludeTestCode, mappedResources); IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(launchConfig); IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspath(unresolved, launchConfig); Set classpaths = new LinkedHashSet<>(); @@ -282,15 +282,18 @@ private static class JavaApplicationLaunchConfiguration extends LaunchConfigurat + "\n" + ""; private IProject project; + private String mainType; private boolean excludeTestCode; private List mappedResources; private String classpathProvider; private String sourcepathProvider; private LaunchConfigurationInfo launchInfo; - protected JavaApplicationLaunchConfiguration(IProject project, boolean excludeTestCode, List mappedResources) throws CoreException { + protected JavaApplicationLaunchConfiguration(IProject project, String mainType, boolean excludeTestCode, List mappedResources) + throws CoreException { super(String.valueOf(new Date().getTime()), null, false); this.project = project; + this.mainType = mainType; this.excludeTestCode = excludeTestCode; this.mappedResources = mappedResources; if (ProjectUtils.isMavenProject(project)) { @@ -319,6 +322,8 @@ public String getAttribute(String attributeName, String defaultValue) throws Cor return classpathProvider; } else if (IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER.equalsIgnoreCase(attributeName)) { return sourcepathProvider; + } else if (IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME.equalsIgnoreCase(attributeName)) { + return mainType; } return super.getAttribute(attributeName, defaultValue);