Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 The Bazel Authors. All rights reserved.
* Copyright 2025 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@
import com.intellij.openapi.util.io.FileUtil;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
Expand Down Expand Up @@ -93,6 +94,12 @@ public File decode(ArtifactLocation artifactLocation) {
private @Nullable File tryToResolveExternalArtifactToMainWorkspace(ArtifactLocation artifactLocation) {
if (artifactLocation.isExternal()) {
try {
Path estimatedLocation = blazeInfo.getExecutionRoot().toPath().resolve(artifactLocation.getExecutionRootRelativePath());
if (!Files.exists(estimatedLocation)) {
LOG.info("Cannot resolve " + estimatedLocation + " because it does not exist");
return null;
}

File realFile = blazeInfo.getExecutionRoot().toPath()
.resolve(artifactLocation.getExecutionRootRelativePath()).toRealPath().toFile();
if (pathResolver.getWorkspacePath(realFile) != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 The Bazel Authors. All rights reserved.
* Copyright 2025 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,8 @@
import com.intellij.openapi.project.Project;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -158,14 +160,19 @@ public ImmutableList<File> resolveToIncludeDirectories(ExecutionRootPath path) {
public ImmutableList<File> resolveToExternalWorkspaceWithSymbolicLinkResolution(
ExecutionRootPath path) {
File fileInExecutionRoot = path.getFileRootedAt(outputBase);

try {
File realPath = fileInExecutionRoot.toPath().toRealPath().toFile();
if (workspacePathResolver.getWorkspacePath(realPath) != null) {
return ImmutableList.of(realPath);
Path pathInExecutionRoot = fileInExecutionRoot.toPath();
if (!Files.exists(pathInExecutionRoot)) {
LOG.info("Cannot resolve " + pathInExecutionRoot + " because it does not exist");
}
else {
try {
File realPath = pathInExecutionRoot.toRealPath().toFile();
if (workspacePathResolver.getWorkspacePath(realPath) != null) {
return ImmutableList.of(realPath);
}
} catch (IOException ioException) {
LOG.warn("Failed to resolve real path for " + fileInExecutionRoot, ioException);
}
} catch (IOException ioException) {
LOG.warn("Failed to resolve real path for " + fileInExecutionRoot, ioException);
}

return ImmutableList.of(fileInExecutionRoot);
Expand Down