1616
1717import java .util .ArrayList ;
1818import java .util .Collection ;
19- import java .util .LinkedHashMap ;
2019import java .util .LinkedHashSet ;
2120import java .util .List ;
2221import java .util .Map ;
23- import java .util .Map .Entry ;
24- import java .util .Optional ;
2522import java .util .Set ;
2623
2724import org .eclipse .core .runtime .CoreException ;
@@ -43,30 +40,11 @@ public class JUnitLaunchRequirements {
4340 public static final String JUNIT4_JDT_RUNTIME_PLUGIN = "org.eclipse.jdt.junit4.runtime" ; //$NON-NLS-1$
4441 public static final String JUNIT5_JDT_RUNTIME_PLUGIN = "org.eclipse.jdt.junit5.runtime" ; //$NON-NLS-1$
4542
46- private static final VersionRange JUNIT5_VERSIONS = new VersionRange ("[1, 6)" ); //$NON-NLS-1$
47-
48- // we add launcher and jupiter.engine to support @RunWith(JUnitPlatform.class)
49- private static final Map <String , List <String >> JUNIT5_RUN_WITH_BUNDLES = new LinkedHashMap <>();
50- static { // consider JUnit bundle names from old Eclipse-Orbit times. Assume either only new or only old names are used.
51- JUNIT5_RUN_WITH_BUNDLES .put ("junit-platform-runner" , List .of ("junit-platform-launcher" , "junit-jupiter-engine" )); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
52- JUNIT5_RUN_WITH_BUNDLES .put ("org.junit.platform.runner" , List .of ("org.junit.platform.launcher" , "org.junit.jupiter.engine" )); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
53- }
54-
5543 public static void addRequiredJunitRuntimePlugins (ILaunchConfiguration configuration , Map <String , List <IPluginModelBase >> allBundles , Map <IPluginModelBase , String > allModels ) throws CoreException {
5644 Collection <String > runtimePlugins = getRequiredJunitRuntimeEclipsePlugins (configuration );
57-
5845 Set <BundleDescription > addedRuntimeBundles = addAbsentRequirements (runtimePlugins , allBundles , allModels );
5946 Set <BundleDescription > runtimeRequirements = DependencyManager .findRequirementsClosure (addedRuntimeBundles );
6047 addAbsentRequirements (runtimeRequirements , allBundles , allModels );
61-
62- if (runtimePlugins .contains (JUNIT5_JDT_RUNTIME_PLUGIN )) {
63- Optional <List <String >> runWithBundles = JUNIT5_RUN_WITH_BUNDLES .entrySet ().stream ().filter (e -> allBundles .containsKey (e .getKey ())).findFirst ().map (Entry ::getValue );
64- if (runWithBundles .isPresent ()) {
65- Set <BundleDescription > descriptions = findBundlesInTargetOrHost (runWithBundles .get (), JUNIT5_VERSIONS );
66- Set <BundleDescription > junitRquirements = DependencyManager .findRequirementsClosure (descriptions );
67- addAbsentRequirements (junitRquirements , allBundles , allModels );
68- }
69- }
7048 }
7149
7250 @ SuppressWarnings ("restriction" )
@@ -123,17 +101,6 @@ private static void addAbsentRequirements(Set<BundleDescription> requirements, M
123101 }
124102 }
125103
126- private static Set <BundleDescription > findBundlesInTargetOrHost (List <String > bundleIDs , VersionRange version ) throws CoreException {
127- Set <BundleDescription > descriptions = new LinkedHashSet <>();
128- for (String id : bundleIDs ) {
129- IPluginModelBase model = findRequiredPluginInTargetOrHost (id , version );
130- if (model != null ) {
131- descriptions .add (model .getBundleDescription ());
132- }
133- }
134- return descriptions ;
135- }
136-
137104 private static IPluginModelBase findRequiredPluginInTargetOrHost (String id , VersionRange version ) throws CoreException {
138105 IPluginModelBase model = version != null ? PluginRegistry .findModel (id , version ) : PluginRegistry .findModel (id );
139106 if (model == null || !model .getBundleDescription ().isResolved ()) {
0 commit comments