Search in sources :

Example 1 with DirCacheEntry

use of com.facebook.buck.artifact_cache.DirCacheEntry in project buck by facebook.

the class IJProjectCleaner method clean.

@SuppressWarnings("serial")
public void clean(final BuckConfig buckConfig, final Path librariesXmlBase, final boolean runPostGenerationCleaner, final boolean removeOldLibraries) {
    if (!runPostGenerationCleaner && !removeOldLibraries) {
        return;
    }
    final Set<File> buckDirectories = new HashSet<>();
    buckDirectories.add(convertPathToFile(projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut())));
    ArtifactCacheBuckConfig cacheBuckConfig = new ArtifactCacheBuckConfig(buckConfig);
    for (DirCacheEntry entry : cacheBuckConfig.getDirCacheEntries()) {
        buckDirectories.add(convertPathToFile(entry.getCacheDir()));
    }
    ForkJoinPool cleanExecutor = new ForkJoinPool(getParallelismLimit());
    try {
        cleanExecutor.invoke(new RecursiveAction() {

            @Override
            protected void compute() {
                List<RecursiveAction> topLevelTasks = new ArrayList<>(2);
                if (runPostGenerationCleaner) {
                    topLevelTasks.add(new CandidateFinderWithExclusions(convertPathToFile(projectFilesystem.resolve("")), IML_FILENAME_FILTER, buckDirectories));
                }
                topLevelTasks.add(new CandidateFinder(convertPathToFile(librariesXmlBase), XML_FILENAME_FILTER));
                invokeAll(topLevelTasks);
            }
        });
    } finally {
        cleanExecutor.shutdown();
        try {
            cleanExecutor.awaitTermination(EXECUTOR_SHUTDOWN_TIMEOUT, EXECUTOR_SHUTDOWN_TIME_UNIT);
        } catch (InterruptedException e) {
            Logger.get(IJProjectCleaner.class).warn("Timeout during executor shutdown.", e);
        }
    }
}
Also used : DirCacheEntry(com.facebook.buck.artifact_cache.DirCacheEntry) RecursiveAction(java.util.concurrent.RecursiveAction) ArtifactCacheBuckConfig(com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) HashSet(java.util.HashSet) ForkJoinPool(java.util.concurrent.ForkJoinPool)

Aggregations

ArtifactCacheBuckConfig (com.facebook.buck.artifact_cache.ArtifactCacheBuckConfig)1 DirCacheEntry (com.facebook.buck.artifact_cache.DirCacheEntry)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 ForkJoinPool (java.util.concurrent.ForkJoinPool)1 RecursiveAction (java.util.concurrent.RecursiveAction)1