|
62 | 62 | import org.eclipse.jdt.core.IType; |
63 | 63 | import org.eclipse.jdt.core.JavaCore; |
64 | 64 | import org.eclipse.jdt.core.JavaModelException; |
| 65 | +import org.eclipse.jdt.internal.junit.buildpath.BuildPathSupport; |
65 | 66 | import org.eclipse.jdt.internal.junit.launcher.ITestKind; |
66 | 67 | import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants; |
67 | 68 | import org.eclipse.jdt.internal.junit.launcher.JUnitRuntimeClasspathEntry; |
@@ -156,6 +157,7 @@ public String showCommandLine(ILaunchConfiguration configuration, String mode, I |
156 | 157 | } |
157 | 158 | } |
158 | 159 |
|
| 160 | + @SuppressWarnings("restriction") |
159 | 161 | private VMRunnerConfiguration getVMRunnerConfiguration(ILaunchConfiguration configuration, ILaunch launch, |
160 | 162 | String mode, IProgressMonitor monitor) throws CoreException { |
161 | 163 | VMRunnerConfiguration runConfig = null; |
@@ -234,14 +236,20 @@ private VMRunnerConfiguration getVMRunnerConfiguration(ILaunchConfiguration conf |
234 | 236 | String[] classpath = classpathAndModulepath[0]; |
235 | 237 | String[] modulepath = classpathAndModulepath[1]; |
236 | 238 |
|
237 | | - if (junitVersion == JUnitVersion.JUNIT5 || junitVersion == JUnitVersion.JUNIT6) { |
| 239 | + boolean isJUnit5 = junitVersion == JUnitVersion.JUNIT5; |
| 240 | + boolean isJUnit6 = junitVersion == JUnitVersion.JUNIT6; |
| 241 | + String junitPlatformVersion = BuildPathSupport.JUNIT6_VERSION; |
| 242 | + if (isJUnit5) { |
| 243 | + junitPlatformVersion = BuildPathSupport.JUNIT_PLATFORM_VERSION; |
| 244 | + } |
| 245 | + if (isJUnit5 || isJUnit6) { |
238 | 246 | if (!configuration.getAttribute( |
239 | 247 | JUnitLaunchConfigurationConstants.ATTR_DONT_ADD_MISSING_JUNIT5_DEPENDENCY, false)) { |
240 | | - if (!Arrays.stream(classpath).anyMatch( |
241 | | - s -> s.contains("junit-platform-launcher") || s.contains("org.junit.platform.launcher"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 248 | + if (!Arrays.stream(classpath).anyMatch(s -> s.contains(BuildPathSupport.JUNIT_PLATFORM_LAUNCHER) |
| 249 | + || s.contains("org.junit.platform.launcher"))) { //$NON-NLS-1$ |
242 | 250 | try { |
243 | | - JUnitRuntimeClasspathEntry x = new JUnitRuntimeClasspathEntry("junit-platform-launcher", //$NON-NLS-1$ |
244 | | - null); |
| 251 | + JUnitRuntimeClasspathEntry x = new JUnitRuntimeClasspathEntry( |
| 252 | + BuildPathSupport.JUNIT_PLATFORM_LAUNCHER, null, junitPlatformVersion); |
245 | 253 | String entryString = new ClasspathLocalizer(Platform.inDevelopmentMode()).entryString(x); |
246 | 254 | int length = classpath.length; |
247 | 255 | System.arraycopy(classpath, 0, classpath = new String[length + 1], 0, length); |
|
0 commit comments