|
23 | 23 | import java.util.Date; |
24 | 24 | import java.util.HashMap; |
25 | 25 | import java.util.HashSet; |
| 26 | +import java.util.LinkedHashMap; |
26 | 27 | import java.util.LinkedHashSet; |
27 | 28 | import java.util.Map; |
28 | 29 | import java.util.Map.Entry; |
@@ -74,8 +75,8 @@ public class JavaBuilder extends IncrementalProjectBuilder { |
74 | 75 | String[] extraResourceFolderFilters; |
75 | 76 | public static final String SOURCE_ID = "JDT"; //$NON-NLS-1$ |
76 | 77 |
|
77 | | -public static boolean DEBUG = false; |
78 | | -public static boolean SHOW_STATS = false; |
| 78 | +public static boolean DEBUG; |
| 79 | +public static boolean SHOW_STATS; |
79 | 80 |
|
80 | 81 | /** |
81 | 82 | * Bug 549457: In case auto-building on a JDT core settings change (e.g. compiler compliance) is not desired, |
@@ -487,7 +488,7 @@ private Map<IProject, IResourceDelta> findDeltas() { |
487 | 488 | } |
488 | 489 | } else { |
489 | 490 | if (DEBUG) { |
490 | | - trace("JavaBuilder: Missing delta for: " + p.getName()); //$NON-NLS-1$ |
| 491 | + trace("JavaBuilder: Missing delta for: " + p.getName()); //$NON-NLS-1$ |
491 | 492 | } |
492 | 493 | this.notifier.subTask(""); //$NON-NLS-1$ |
493 | 494 | return null; |
@@ -527,13 +528,33 @@ private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) { |
527 | 528 | case IClasspathEntry.CPE_LIBRARY : |
528 | 529 | if (includeBinaryPrerequisites && path.segmentCount() > 0) { |
529 | 530 | // some binary resources on the class path can come from projects that are not included in the project references |
530 | | - IResource resource = this.workspaceRoot.findMember(path.segment(0)); |
531 | | - if (resource instanceof IProject) { |
532 | | - p = (IProject) resource; |
533 | | - } else { |
| 531 | + IResource resource = null; |
| 532 | + |
| 533 | + // Try to check first if the full binary entry path exactly matches an external folder, |
| 534 | + // before assuming it's first segment matches some project name in the workspace |
| 535 | + if (ExternalFoldersManager.isExternalFolderPath(path)) { |
534 | 536 | resource = externalFoldersManager.getFolder(path); |
535 | | - if (resource != null) |
536 | | - p = resource.getProject(); |
| 537 | + if (DEBUG && resource != null && !path.lastSegment().contains("jrt-fs.jar")) { //$NON-NLS-1$ |
| 538 | + trace("JavaBuilder: found resource containing binary classpath entry: \nExternal: " + this.currentProject.getName() + " -> " + path); //$NON-NLS-1$ //$NON-NLS-2$ |
| 539 | + } |
| 540 | + } |
| 541 | + |
| 542 | + // Second try: it could be a full workspace path, where first segment is the project name. |
| 543 | + // Note, the path may not exist physically yet, it is allowed to reference not (yet) existing resources. |
| 544 | + // Unfortunately this can also match fully unrelated projects in the workspace on Linux/Mac, |
| 545 | + // current .classpath format does not provide possibilities to ensure that |
| 546 | + // "<classpathentry kind="lib" path="/some/folder/name"/>" |
| 547 | + // specifies an absolute OS path or full workspace path, both may not exist yet. |
| 548 | + if (resource == null && path.isAbsolute() && path.getDevice() == null) { |
| 549 | + resource = this.workspaceRoot.findMember(path.segment(0)); |
| 550 | + } |
| 551 | + |
| 552 | + if (resource != null) { |
| 553 | + p = resource.getProject(); |
| 554 | + } else { |
| 555 | + if (DEBUG && !path.lastSegment().contains("jrt-fs.jar")) { //$NON-NLS-1$ |
| 556 | + trace("JavaBuilder: Could not find resource containing binary classpath entry: \n" + this.currentProject.getName() + " -> " + path); //$NON-NLS-1$ //$NON-NLS-2$ |
| 557 | + } |
537 | 558 | } |
538 | 559 | } |
539 | 560 | } |
@@ -695,7 +716,7 @@ private int initializeBuilder(int kind, boolean forBuild) throws CoreException { |
695 | 716 | } |
696 | 717 | } |
697 | 718 |
|
698 | | - this.binaryLocationsPerProject = new HashMap<>(3); |
| 719 | + this.binaryLocationsPerProject = new LinkedHashMap<>(3); |
699 | 720 | this.nameEnvironment = new NameEnvironment(this.workspaceRoot, this.javaProject, this.binaryLocationsPerProject, this.notifier, CompilationGroup.MAIN, JavaProject.NO_RELEASE); |
700 | 721 | this.testNameEnvironment = new NameEnvironment(this.workspaceRoot, this.javaProject, this.binaryLocationsPerProject, this.notifier, CompilationGroup.TEST, JavaProject.NO_RELEASE); |
701 | 722 |
|
|
0 commit comments