|
24 | 24 | import java.nio.file.Path; |
25 | 25 | import java.util.ArrayList; |
26 | 26 | import java.util.Arrays; |
| 27 | +import java.util.Collection; |
27 | 28 | import java.util.Collections; |
28 | 29 | import java.util.Comparator; |
| 30 | +import java.util.Iterator; |
29 | 31 | import java.util.LinkedHashMap; |
30 | 32 | import java.util.List; |
31 | 33 | import java.util.Map; |
|
82 | 84 | import org.eclipse.pde.internal.launching.launcher.RequirementHelper; |
83 | 85 | import org.eclipse.pde.internal.launching.launcher.VMHelper; |
84 | 86 | import org.osgi.framework.Constants; |
| 87 | +import org.osgi.framework.Version; |
| 88 | +import org.osgi.framework.hooks.resolver.ResolverHook; |
| 89 | +import org.osgi.framework.wiring.BundleCapability; |
| 90 | +import org.osgi.framework.wiring.BundleRequirement; |
| 91 | +import org.osgi.framework.wiring.BundleRevision; |
85 | 92 |
|
86 | 93 | /** |
87 | 94 | * A launch delegate for launching JUnit Plug-in tests. |
@@ -611,6 +618,46 @@ protected void validateProjectDependencies(ILaunchConfiguration configuration, I |
611 | 618 | */ |
612 | 619 | protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { |
613 | 620 | EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet(), launchMode); |
| 621 | + op.setResolverHook(new ResolverHook() { |
| 622 | + |
| 623 | + @Override |
| 624 | + public void filterResolvable(Collection<BundleRevision> candidates) { |
| 625 | + } |
| 626 | + |
| 627 | + @Override |
| 628 | + public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) { |
| 629 | + } |
| 630 | + |
| 631 | + @SuppressWarnings("restriction") |
| 632 | + @Override |
| 633 | + public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) { |
| 634 | + org.eclipse.jdt.internal.junit.launcher.ITestKind testKind = org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants.getTestRunnerKind(configuration); |
| 635 | + if (org.eclipse.jdt.internal.junit.launcher.TestKindRegistry.JUNIT5_TEST_KIND_ID.equals(testKind.getId())) { |
| 636 | + String name = requirement.getResource().getSymbolicName(); |
| 637 | + if (!name.startsWith("junit") && !name.startsWith("org.junit")) { |
| 638 | + Iterator<BundleCapability> iterator = candidates.iterator(); |
| 639 | + while (iterator.hasNext()) { |
| 640 | + BundleCapability candidate = iterator.next(); |
| 641 | + String cn = candidate.getResource().getSymbolicName(); |
| 642 | + Version cv = candidate.getResource().getVersion(); |
| 643 | + if (cn.startsWith("junit") || cn.startsWith("org.junit")) { |
| 644 | + if (cv.getMajor() == 6) { |
| 645 | + Version version = requirement.getResource().getVersion(); |
| 646 | + System.out.println("Requirement: " + name + " " + version); |
| 647 | + System.out.println(" Candidate: " + cn + " " + candidate); |
| 648 | + iterator.remove(); |
| 649 | + } |
| 650 | + } |
| 651 | + } |
| 652 | + } |
| 653 | + } |
| 654 | + } |
| 655 | + |
| 656 | + @Override |
| 657 | + public void end() { |
| 658 | + } |
| 659 | + |
| 660 | + }); |
614 | 661 | LaunchPluginValidator.runValidationOperation(op, monitor); |
615 | 662 | } |
616 | 663 | } |
0 commit comments