Search in sources :

Example 1 with ExternalAndroidLibrary

use of com.android.projectmodel.ExternalAndroidLibrary in project intellij by bazelbuild.

the class BlazeModuleSystem method getLibrariesForWorkspaceModule.

private static ImmutableList<ExternalAndroidLibrary> getLibrariesForWorkspaceModule(Project project, BlazeProjectData blazeProjectData) {
    ArtifactLocationDecoder decoder = blazeProjectData.getArtifactLocationDecoder();
    ExternalLibraryInterner externalLibraryInterner = ExternalLibraryInterner.getInstance(project);
    ImmutableList.Builder<ExternalAndroidLibrary> libraries = ImmutableList.builder();
    for (BlazeLibrary library : BlazeLibraryCollector.getLibraries(ProjectViewManager.getInstance(project).getProjectViewSet(), blazeProjectData)) {
        if (library instanceof AarLibrary) {
            ExternalAndroidLibrary externalLibrary = toExternalLibrary(project, (AarLibrary) library, decoder);
            if (externalLibrary != null) {
                libraries.add(externalLibraryInterner.intern(externalLibrary));
            }
        }
    }
    return libraries.build();
}
Also used : AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) ImmutableList(com.google.common.collect.ImmutableList) ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)

Example 2 with ExternalAndroidLibrary

use of com.android.projectmodel.ExternalAndroidLibrary in project intellij by bazelbuild.

the class BlazeModuleSystem method getDependentLibraries.

public Collection<ExternalAndroidLibrary> getDependentLibraries() {
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (blazeProjectData == null) {
        return ImmutableList.of();
    }
    if (isWorkspaceModule) {
        return SyncCache.getInstance(project).get(BlazeModuleSystem.class, BlazeModuleSystem::getLibrariesForWorkspaceModule);
    }
    AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
    TargetIdeInfo target = blazeProjectData.getTargetMap().get(registry.getTargetKey(module));
    if (target == null) {
        // no dependent libraries
        return ImmutableList.of();
    }
    BlazeAndroidSyncData androidSyncData = blazeProjectData.getSyncState().get(BlazeAndroidSyncData.class);
    if (androidSyncData == null) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<ExternalAndroidLibrary> libraries = ImmutableList.builder();
    ArtifactLocationDecoder decoder = blazeProjectData.getArtifactLocationDecoder();
    ExternalLibraryInterner externalLibraryInterner = ExternalLibraryInterner.getInstance(project);
    for (String libraryKey : registry.get(module).resourceLibraryKeys) {
        ImmutableMap<String, AarLibrary> aarLibraries = androidSyncData.importResult.aarLibraries;
        ExternalAndroidLibrary externalLibrary = toExternalLibrary(project, aarLibraries.get(libraryKey), decoder);
        if (externalLibrary != null) {
            libraries.add(externalLibraryInterner.intern(externalLibrary));
        }
    }
    return libraries.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) PathString(com.android.ide.common.util.PathString) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) AarLibrary(com.google.idea.blaze.android.sync.model.AarLibrary) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) BlazeAndroidSyncData(com.google.idea.blaze.android.sync.model.BlazeAndroidSyncData)

Example 3 with ExternalAndroidLibrary

use of com.android.projectmodel.ExternalAndroidLibrary in project intellij by bazelbuild.

the class BlazeModuleSystemDependentLibrariesIntegrationTest method getDependencies_workspaceModule.

@Test
public void getDependencies_workspaceModule() {
    PathString rootPath = new PathString(workspaceRoot.directory());
    Collection<ExternalAndroidLibrary> libraries = workspaceModuleSystem.getDependentLibraries();
    assertThat(new ArrayList<>(libraries)).containsExactly(getAarLibrary(rootPath, "third_party/quantum/values-third_party-quantum-res.aar", "third_party.quantum"), getAarLibrary(rootPath, "java/com/google/app-third_party-shared-res.aar", "com.google"), getAarLibrary(rootPath, "third_party/constraint_layout/constraint_layout-third_party-constraint_layout-res.aar", "third_party.constraint_layout"), getAarLibrary(rootPath, "third_party/aar/lib_aar.aar", "third_party.aar"));
}
Also used : ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) ArrayList(java.util.ArrayList) PathString(com.android.ide.common.util.PathString) Test(org.junit.Test)

Example 4 with ExternalAndroidLibrary

use of com.android.projectmodel.ExternalAndroidLibrary in project intellij by bazelbuild.

the class BlazeModuleSystemDependentLibrariesIntegrationTest method getDependencies_appModule.

@Test
public void getDependencies_appModule() {
    PathString rootPath = new PathString(workspaceRoot.directory());
    Collection<ExternalAndroidLibrary> libraries = appModuleSystem.getDependentLibraries();
    assertThat(new ArrayList<>(libraries)).containsExactly(getAarLibrary(rootPath, "third_party/aar/lib_aar.aar", "third_party.aar"), getAarLibrary(rootPath, "java/com/google/app-third_party-shared-res.aar", "com.google"), getAarLibrary(rootPath, "third_party/constraint_layout/constraint_layout-third_party-constraint_layout-res.aar", "third_party.constraint_layout"), getAarLibrary(rootPath, "third_party/quantum/values-third_party-quantum-res.aar", "third_party.quantum"));
}
Also used : ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) ArrayList(java.util.ArrayList) PathString(com.android.ide.common.util.PathString) Test(org.junit.Test)

Aggregations

ExternalAndroidLibrary (com.android.projectmodel.ExternalAndroidLibrary)4 PathString (com.android.ide.common.util.PathString)3 ImmutableList (com.google.common.collect.ImmutableList)2 AarLibrary (com.google.idea.blaze.android.sync.model.AarLibrary)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AndroidResourceModuleRegistry (com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry)1 BlazeAndroidSyncData (com.google.idea.blaze.android.sync.model.BlazeAndroidSyncData)1 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)1 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)1 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1