Skip to content

Commit 5aef753

Browse files
authored
Ignore workspaces defined in install base. (#30)
Fixes #25.
1 parent 776ee11 commit 5aef753

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/BazelWorkspace.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,16 @@ public BazelWorkspace getExternalWorkspace(IPath externalRoot) throws IllegalArg
481481
return new BazelWorkspace(externalRoot, this);
482482
}
483483

484+
/**
485+
* {@return absolute file system location to the Bazel install base}
486+
*
487+
* @throws CoreException
488+
* if the workspace does not exist
489+
*/
490+
public IPath getInstallBaseLocation() throws CoreException {
491+
return getInfo().getInstallBase();
492+
}
493+
484494
@Override
485495
public BazelLabel getLabel() {
486496
// FIXME: the workspace should have a label but which one? @, @//, @name?

bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/BazelWorkspaceInfo.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private enum BazelInfoKey {
6666
BAZEL_TESTLOGS("bazel-testlogs"),
6767
COMMAND_LOG("command_log"),
6868
OUTPUT_BASE("output_base"),
69+
INSTALL_BASE("install_base"),
6970
OUTPUT_PATH("output_path"),
7071
STARLARK_SEMANTICS("starlark-semantics");
7172

@@ -106,6 +107,7 @@ public String key() {
106107
private IPath bazelGenfiles;
107108
private IPath bazelTestlogs;
108109
private IPath commandLog;
110+
private IPath installBase;
109111
private IPath outputBase;
110112
private IPath outputPath;
111113
private String starlarkSemantics;
@@ -268,6 +270,10 @@ public Stream<ExternalWorkspace> getExternalRepositoryMappings() throws CoreExce
268270
return externalWorkspaceByRepoName.values().stream();
269271
}
270272

273+
public IPath getInstallBase() {
274+
return installBase;
275+
}
276+
271277
public String getName() {
272278
return name;
273279
}
@@ -434,6 +440,7 @@ public void load(BazelModelCommandExecutionService executionService) throws Core
434440
bazelGenfiles = getExpectedOutputAsPath(infoResult, BazelInfoKey.BAZEL_GENFILES);
435441
bazelTestlogs = getExpectedOutputAsPath(infoResult, BazelInfoKey.BAZEL_TESTLOGS);
436442
commandLog = getExpectedOutputAsPath(infoResult, BazelInfoKey.COMMAND_LOG);
443+
installBase = getExpectedOutputAsPath(infoResult, BazelInfoKey.INSTALL_BASE);
437444
outputBase = getExpectedOutputAsPath(infoResult, BazelInfoKey.OUTPUT_BASE);
438445
outputPath = getExpectedOutputAsPath(infoResult, BazelInfoKey.OUTPUT_PATH);
439446
starlarkSemantics = getExpectedOutput(infoResult, BazelInfoKey.STARLARK_SEMANTICS);
@@ -503,6 +510,22 @@ public void load(BazelModelCommandExecutionService executionService) throws Core
503510
}
504511
}
505512

513+
private synchronized Map<String, ExternalWorkspace> loadExternalRepoMappings() throws CoreException {
514+
if (externalWorkspaceByRepoName != null) {
515+
return externalWorkspaceByRepoName;
516+
}
517+
518+
var workspaceRoot = getWorkspaceFile().getParent();
519+
520+
var repoMappingCommand =
521+
new BazelModDumpRepoMappingCommand(workspaceRoot, "", "Reading bzlmod repository mappings");
522+
List<ExternalWorkspace> externalWorkspaces =
523+
bazelWorkspace.getCommandExecutor().runQueryWithoutLock(repoMappingCommand);
524+
525+
return externalWorkspaceByRepoName =
526+
externalWorkspaces.stream().collect(toMap(ExternalWorkspace::repoName, Function.identity())); // index by the "repo name" attribute
527+
}
528+
506529
private synchronized Map<String, BazelRuleAttributes> loadExternalRepositoryRules() throws CoreException {
507530
if (externalRepositoryRuleByName != null) {
508531
return externalRepositoryRuleByName;
@@ -529,20 +552,4 @@ private synchronized Map<String, BazelRuleAttributes> loadExternalRepositoryRule
529552
.map(BazelRuleAttributes::new)
530553
.collect(toMap(BazelRuleAttributes::getName, Function.identity())); // index by the "name" attribute
531554
}
532-
533-
private synchronized Map<String, ExternalWorkspace> loadExternalRepoMappings() throws CoreException {
534-
if (externalWorkspaceByRepoName != null) {
535-
return externalWorkspaceByRepoName;
536-
}
537-
538-
var workspaceRoot = getWorkspaceFile().getParent();
539-
540-
var repoMappingCommand =
541-
new BazelModDumpRepoMappingCommand(workspaceRoot, "", "Reading bzlmod repository mappings");
542-
List<ExternalWorkspace> externalWorkspaces =
543-
bazelWorkspace.getCommandExecutor().runQueryWithoutLock(repoMappingCommand);
544-
545-
return externalWorkspaceByRepoName =
546-
externalWorkspaces.stream().collect(toMap(ExternalWorkspace::repoName, Function.identity())); // index by the "repo name" attribute
547-
}
548555
}

bundles/com.salesforce.bazel.eclipse.core/src/com/salesforce/bazel/eclipse/core/model/discovery/JavaAspectsClasspathInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,11 @@ private BazelWorkspace findExternalWorkspace(Label label) throws CoreException {
475475
var path = forPosix(pathAttribute);
476476
if (!path.isAbsolute()) {
477477
path = bazelWorkspace.getLocation().append(path);
478+
} else if (bazelWorkspace.getInstallBaseLocation().isPrefixOf(path)) {
479+
// if this is coming from the install base we must ignore it
480+
// fixes https://github.com/eclipseguru/bazel-eclipse/issues/25
481+
return null;
482+
// TODO: should we check for other paths here as well, like output_base? Are those plausible here?
478483
}
479484

480485
// check if path exists but here we expect it to be a proper Bazel workspace (not in output_base/external)

0 commit comments

Comments
 (0)