Search in sources :

Example 1 with TransitiveResourceMap

use of com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap 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 2 with TransitiveResourceMap

use of com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporter method addSourceTarget.

private void addSourceTarget(WorkspaceBuilder workspaceBuilder, TransitiveResourceMap transitiveResourceMap, TargetIdeInfo target) {
    AndroidIdeInfo androidIdeInfo = target.androidIdeInfo;
    assert androidIdeInfo != null;
    if (shouldGenerateResources(androidIdeInfo) && shouldGenerateResourceModule(androidIdeInfo, whitelistedGenResourcePaths)) {
        AndroidResourceModule.Builder builder = new AndroidResourceModule.Builder(target.key);
        workspaceBuilder.androidResourceModules.add(builder);
        for (ArtifactLocation artifactLocation : androidIdeInfo.resources) {
            if (artifactLocation.isSource()) {
                builder.addResource(artifactLocation);
            } else {
                workspaceBuilder.generatedResourceLocations.add(artifactLocation);
                if (whitelistedGenResourcePaths.contains(artifactLocation.relativePath)) {
                    // Still track location in generatedResourceLocations, so that we can warn if a
                    // whitelist entry goes unused and can be removed.
                    builder.addResource(artifactLocation);
                }
            }
        }
        TransitiveResourceMap.TransitiveResourceInfo transitiveResourceInfo = transitiveResourceMap.get(target.key);
        for (ArtifactLocation artifactLocation : transitiveResourceInfo.transitiveResources) {
            if (artifactLocation.isSource()) {
                builder.addTransitiveResource(artifactLocation);
            } else {
                workspaceBuilder.generatedResourceLocations.add(artifactLocation);
                if (whitelistedGenResourcePaths.contains(artifactLocation.relativePath)) {
                    builder.addTransitiveResource(artifactLocation);
                }
            }
        }
        for (TargetKey resourceDependency : transitiveResourceInfo.transitiveResourceTargets) {
            if (!resourceDependency.equals(target.key)) {
                builder.addTransitiveResourceDependency(resourceDependency);
            }
        }
    }
}
Also used : AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) TransitiveResourceMap(com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo)

Aggregations

TransitiveResourceMap (com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap)2 AndroidResourceModule (com.google.idea.blaze.android.sync.model.AndroidResourceModule)2 AndroidIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidIdeInfo)2 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)2 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 ComparisonChain (com.google.common.collect.ComparisonChain)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Multimap (com.google.common.collect.Multimap)1 Sets (com.google.common.collect.Sets)1 GeneratedAndroidResourcesSection (com.google.idea.blaze.android.projectview.GeneratedAndroidResourcesSection)1 GeneratedResourceWarnings (com.google.idea.blaze.android.sync.importer.problems.GeneratedResourceWarnings)1 AarLibrary (com.google.idea.blaze.android.sync.model.AarLibrary)1 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)1 BlazeResourceLibrary (com.google.idea.blaze.android.sync.model.BlazeResourceLibrary)1 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)1 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)1 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)1