Search in sources :

Example 21 with BlazeLibrary

use of com.google.idea.blaze.base.model.BlazeLibrary in project intellij by bazelbuild.

the class UnpackedAars method getArtifactsToCache.

/**
 * Returns a map from cache key to {@link AarLibraryContents}, for all the artifacts which should
 * be cached.
 */
private static ImmutableMap<String, AarLibraryContents> getArtifactsToCache(ProjectViewSet projectViewSet, BlazeProjectData projectData) {
    Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, projectData);
    List<AarLibrary> aarLibraries = libraries.stream().filter(library -> library instanceof AarLibrary).map(library -> (AarLibrary) library).collect(Collectors.toList());
    ArtifactLocationDecoder decoder = projectData.getArtifactLocationDecoder();
    Map<String, AarLibraryContents> outputs = new HashMap<>();
    for (AarLibrary library : aarLibraries) {
        BlazeArtifact aar = decoder.resolveOutput(library.aarArtifact);
        BlazeArtifact jar = library.libraryArtifact != null ? decoder.resolveOutput(library.libraryArtifact.jarForIntellijLibrary()) : null;
        outputs.put(UnpackedAarUtils.getAarDirName(aar), AarLibraryContents.create(aar, jar));
    }
    return ImmutableMap.copyOf(outputs);
}
Also used : BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) FileCacheDiffer(com.google.idea.blaze.base.filecache.FileCacheDiffer) HashMap(java.util.HashMap) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager) HashSet(java.util.HashSet) FileCache(com.google.idea.blaze.base.filecache.FileCache) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) Map(java.util.Map) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) Project(com.intellij.openapi.project.Project) BlazeBuildOutputs(com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(javax.annotation.Nullable) RemoteOutputArtifacts(com.google.idea.blaze.base.model.RemoteOutputArtifacts) ImmutableMap(com.google.common.collect.ImmutableMap) BlazeLibraryCollector(com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector) Collection(java.util.Collection) FutureUtil(com.google.idea.blaze.base.async.FutureUtil) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) Set(java.util.Set) IOException(java.io.IOException) RemoteArtifactPrefetcher(com.google.idea.blaze.base.prefetch.RemoteArtifactPrefetcher) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) File(java.io.File) BlazeArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) ExecutionException(java.util.concurrent.ExecutionException) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) SyncMode(com.google.idea.blaze.base.sync.SyncMode) LocalFileArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact.LocalFileArtifact) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) HashMap(java.util.HashMap) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) BlazeArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)

Aggregations

BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)21 ImmutableList (com.google.common.collect.ImmutableList)8 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)7 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)7 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)6 Library (com.intellij.openapi.roots.libraries.Library)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)5 Project (com.intellij.openapi.project.Project)5 File (java.io.File)5 Nullable (javax.annotation.Nullable)5 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)4 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)4 PrintOutput (com.google.idea.blaze.base.scope.output.PrintOutput)4 BlazeDataStorage (com.google.idea.blaze.base.sync.data.BlazeDataStorage)4 BlazeLibraryCollector (com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector)4 Logger (com.intellij.openapi.diagnostic.Logger)4 Collection (java.util.Collection)4 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)3