Skip to content

[AOSP-pick] Enumerate all currently used cache directories. #7360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
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
Expand Up @@ -153,9 +153,10 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException
ProjectProtoTransform.Registry projectTransformRegistry = new Registry();
SnapshotHolder graph = new SnapshotHolder();
graph.addListener((c, i) -> projectModificationTracker.incModificationCount());
Path buildCachePath = getBuildCachePath(project);
BuildArtifactCache artifactCache =
BuildArtifactCache.create(
ideProjectBasePath.resolve(".buildcache"),
buildCachePath,
createArtifactFetcher(),
executor,
QuerySyncManager.getInstance(project).cacheCleanRequest());
Expand Down Expand Up @@ -266,6 +267,10 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException
return querySyncProject;
}

public static Path getBuildCachePath(Project project) {
return Paths.get(checkNotNull(project.getBasePath())).resolve(".buildcache");
}

private ParallelPackageReader createWorkspaceRelativePackageReader() {
return new ParallelPackageReader(executor, new PackageStatementParser());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@
*/
package com.google.idea.blaze.base.sync.data;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.idea.blaze.base.logging.LoggedDirectoryProvider;
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.google.idea.blaze.base.qsync.ProjectLoader;
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.settings.BlazeImportSettings;
import com.google.idea.blaze.base.settings.BlazeImportSettingsManager;
import com.google.idea.blaze.qsync.deps.ArtifactDirectories;
import com.google.idea.blaze.qsync.project.ProjectPath;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.project.Project;
import java.io.File;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Optional;

/** Defines where we store our blaze project data. */
Expand Down Expand Up @@ -66,6 +75,28 @@ private static File getProjectConfigurationDir() {
return new File(PathManager.getSystemPath(), "blaze/projects").getAbsoluteFile();
}

/**
* DO NOT USE: Returns a best-effort list of all project data directories used by the IDE.
*/
public static Collection<Path> getMaybeAllProjectDataDirs(Project project) {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project)
.getImportSettings();
if (importSettings == null) {
throw new IllegalStateException("BlazeImportSettings unavailable");
}
final var pathResolver =
ProjectPath.Resolver.create(
WorkspaceRoot.fromImportSettings(importSettings).path(),
Path.of(
importSettings
.getProjectDataDirectory()));
return ImmutableList.of(
getProjectDataDir(importSettings).toPath(),
pathResolver.resolve(ArtifactDirectories.ROOT),
ProjectLoader.getBuildCachePath(project)
);
}

/**
* Configuration which includes the plugin's own project-specific data directory (used for
* artifacts related to IntelliJ's project setup - module configurations, locally cached jars,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/** Static helpers for managing directories in the project artifact store. */
public class ArtifactDirectories {

private static final ProjectPath ROOT = ProjectPath.projectRelative(".bazel");
public static final ProjectPath ROOT = ProjectPath.projectRelative(".bazel");

/**
* By default, all project artifacts go in this directory, at a path matching their bazel output
Expand Down