Skip to content

Commit 8de2814

Browse files
Fix gradle test scope (#333)
* Fix gradle test scope Signed-off-by: Jinbo Wang <[email protected]> * make checkstyle happy Signed-off-by: Jinbo Wang <[email protected]>
1 parent b7f00af commit 8de2814

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveClasspathsHandler.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private static String[][] computeClassPath(String mainClass, String projectName)
182182
IJavaElement testElement = findMainClassInTestFolders(project, mainClass);
183183
List<IResource> mappedResources = (testElement != null && testElement.getResource() != null)
184184
? Arrays.asList(testElement.getResource()) : Collections.EMPTY_LIST;
185-
return computeClassPath(project, testElement == null, mappedResources);
185+
return computeClassPath(project, mainClass, testElement == null, mappedResources);
186186
}
187187

188188
/**
@@ -195,13 +195,13 @@ private static String[][] computeClassPath(String mainClass, String projectName)
195195
* @throws CoreException
196196
* CoreException
197197
*/
198-
private static String[][] computeClassPath(IJavaProject javaProject, boolean excludeTestCode, List<IResource> mappedResources)
198+
private static String[][] computeClassPath(IJavaProject javaProject, String mainType, boolean excludeTestCode, List<IResource> mappedResources)
199199
throws CoreException {
200200
if (javaProject == null) {
201201
throw new IllegalArgumentException("javaProject is null");
202202
}
203203

204-
ILaunchConfiguration launchConfig = new JavaApplicationLaunchConfiguration(javaProject.getProject(), excludeTestCode, mappedResources);
204+
ILaunchConfiguration launchConfig = new JavaApplicationLaunchConfiguration(javaProject.getProject(), mainType, excludeTestCode, mappedResources);
205205
IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(launchConfig);
206206
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspath(unresolved, launchConfig);
207207
Set<String> classpaths = new LinkedHashSet<>();
@@ -282,15 +282,18 @@ private static class JavaApplicationLaunchConfiguration extends LaunchConfigurat
282282
+ "</listAttribute>\n"
283283
+ "</launchConfiguration>";
284284
private IProject project;
285+
private String mainType;
285286
private boolean excludeTestCode;
286287
private List<IResource> mappedResources;
287288
private String classpathProvider;
288289
private String sourcepathProvider;
289290
private LaunchConfigurationInfo launchInfo;
290291

291-
protected JavaApplicationLaunchConfiguration(IProject project, boolean excludeTestCode, List<IResource> mappedResources) throws CoreException {
292+
protected JavaApplicationLaunchConfiguration(IProject project, String mainType, boolean excludeTestCode, List<IResource> mappedResources)
293+
throws CoreException {
292294
super(String.valueOf(new Date().getTime()), null, false);
293295
this.project = project;
296+
this.mainType = mainType;
294297
this.excludeTestCode = excludeTestCode;
295298
this.mappedResources = mappedResources;
296299
if (ProjectUtils.isMavenProject(project)) {
@@ -319,6 +322,8 @@ public String getAttribute(String attributeName, String defaultValue) throws Cor
319322
return classpathProvider;
320323
} else if (IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER.equalsIgnoreCase(attributeName)) {
321324
return sourcepathProvider;
325+
} else if (IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME.equalsIgnoreCase(attributeName)) {
326+
return mainType;
322327
}
323328

324329
return super.getAttribute(attributeName, defaultValue);

0 commit comments

Comments
 (0)