Search in sources :

Example 1 with AarLibrary

use of com.google.idea.blaze.android.sync.model.AarLibrary in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporter method createAarLibraries.

private ImmutableList<AarLibrary> createAarLibraries(Iterable<TargetIdeInfo> libraryTargets) {
    ImmutableList.Builder<AarLibrary> builder = ImmutableList.builder();
    for (TargetIdeInfo target : libraryTargets) {
        // don't have the equivalent of jdeps data.
        if (target.androidAarIdeInfo == null || target.javaIdeInfo == null || target.javaIdeInfo.jars.isEmpty()) {
            continue;
        }
        // aar_import should only have one jar (a merged jar from the AAR's jars).
        LibraryArtifact firstJar = target.javaIdeInfo.jars.iterator().next();
        builder.add(new AarLibrary(firstJar, target.androidAarIdeInfo.aar));
    }
    return builder.build();
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) ImmutableList(com.google.common.collect.ImmutableList) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact)

Example 2 with AarLibrary

use of com.google.idea.blaze.android.sync.model.AarLibrary in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporter method importWorkspace.

public BlazeAndroidImportResult importWorkspace() {
    List<TargetIdeInfo> sourceTargets = targetMap.targets().stream().filter(target -> target.kind.languageClass == LanguageClass.ANDROID).filter(target -> target.androidIdeInfo != null).filter(importFilter::isSourceTarget).filter(target -> !importFilter.excludeTarget(target)).collect(Collectors.toList());
    TransitiveResourceMap transitiveResourceMap = new TransitiveResourceMap(targetMap);
    WorkspaceBuilder workspaceBuilder = new WorkspaceBuilder();
    for (TargetIdeInfo target : sourceTargets) {
        addSourceTarget(workspaceBuilder, transitiveResourceMap, target);
    }
    GeneratedResourceWarnings.submit(project, context, projectViewSet, artifactLocationDecoder, workspaceBuilder.generatedResourceLocations, whitelistedGenResourcePaths);
    ImmutableList<AndroidResourceModule> androidResourceModules = buildAndroidResourceModules(workspaceBuilder);
    BlazeResourceLibrary resourceLibrary = createResourceLibrary(androidResourceModules);
    ImmutableList<AarLibrary> aarLibraries = createAarLibraries(sourceFilter.getLibraryTargets());
    return new BlazeAndroidImportResult(androidResourceModules, resourceLibrary, aarLibraries, getJavacJar(targetMap.targets()));
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) ArrayListMultimap(com.google.common.collect.ArrayListMultimap) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) GeneratedAndroidResourcesSection(com.google.idea.blaze.android.projectview.GeneratedAndroidResourcesSection) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) Multimap(com.google.common.collect.Multimap) BlazeResourceLibrary(com.google.idea.blaze.android.sync.model.BlazeResourceLibrary) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) Kind(com.google.idea.blaze.base.model.primitives.Kind) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) Project(com.intellij.openapi.project.Project) TransitiveResourceMap(com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap) ProjectViewTargetImportFilter(com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) JavaSourceFilter(com.google.idea.blaze.java.sync.importer.JavaSourceFilter) ImmutableSet(com.google.common.collect.ImmutableSet) AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Collection(java.util.Collection) Set(java.util.Set) ComparisonChain(com.google.common.collect.ComparisonChain) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) BlazeAndroidImportResult(com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) GeneratedResourceWarnings(com.google.idea.blaze.android.sync.importer.problems.GeneratedResourceWarnings) List(java.util.List) Stream(java.util.stream.Stream) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) Collections(java.util.Collections) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) BlazeAndroidImportResult(com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult) TransitiveResourceMap(com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap) BlazeResourceLibrary(com.google.idea.blaze.android.sync.model.BlazeResourceLibrary)

Example 3 with AarLibrary

use of com.google.idea.blaze.android.sync.model.AarLibrary in project intellij by bazelbuild.

the class UnpackedAars method onSync.

void onSync(BlazeContext context, ProjectViewSet projectViewSet, BlazeProjectData projectData, BlazeSyncParams.SyncMode syncMode) {
    Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, projectData);
    boolean fullRefresh = syncMode == SyncMode.FULL;
    boolean removeMissingFiles = syncMode == SyncMode.INCREMENTAL;
    if (!enabled || fullRefresh) {
        clearCache();
    }
    if (!enabled) {
        return;
    }
    List<AarLibrary> aarLibraries = libraries.stream().filter(library -> library instanceof AarLibrary).map(library -> (AarLibrary) library).collect(Collectors.toList());
    ArtifactLocationDecoder artifactLocationDecoder = projectData.artifactLocationDecoder;
    BiMap<File, String> sourceAarFileToCacheKey = HashBiMap.create(aarLibraries.size());
    BiMap<File, String> sourceJarFileToCacheKey = HashBiMap.create(aarLibraries.size());
    for (AarLibrary library : aarLibraries) {
        File aarFile = artifactLocationDecoder.decode(library.aarArtifact);
        String cacheKey = cacheKeyForAar(aarFile);
        sourceAarFileToCacheKey.put(aarFile, cacheKey);
        File jarFile = artifactLocationDecoder.decode(library.libraryArtifact.jarForIntellijLibrary());
        // Use the aar key for the jar as well.
        sourceJarFileToCacheKey.put(jarFile, cacheKey);
    }
    this.aarTraits = new AarTraits(cacheDir, sourceAarFileToCacheKey);
    this.jarTraits = new JarTraits(cacheDir, sourceJarFileToCacheKey);
    refresh(context, removeMissingFiles);
}
Also used : SyncMode(com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SdkConstants(com.android.SdkConstants) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) FileCache(com.google.idea.blaze.base.filecache.FileCache) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ImmutableList(com.google.common.collect.ImmutableList) 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) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(javax.annotation.Nullable) BiMap(com.google.common.collect.BiMap) Files(java.nio.file.Files) BlazeLibraryCollector(com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector) Collection(java.util.Collection) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) IOException(java.io.IOException) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) HashBiMap(com.google.common.collect.HashBiMap) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) FileCacheSynchronizerTraits(com.google.idea.blaze.base.filecache.FileCacheSynchronizerTraits) Paths(java.nio.file.Paths) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Preconditions(com.google.common.base.Preconditions) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) ZipUtil(com.intellij.util.io.ZipUtil) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) File(java.io.File)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)3 AarLibrary (com.google.idea.blaze.android.sync.model.AarLibrary)3 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)2 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 Project (com.intellij.openapi.project.Project)2 Collection (java.util.Collection)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 SdkConstants (com.android.SdkConstants)1 Preconditions (com.google.common.base.Preconditions)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 BiMap (com.google.common.collect.BiMap)1 ComparisonChain (com.google.common.collect.ComparisonChain)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Multimap (com.google.common.collect.Multimap)1