Search in sources :

Example 11 with LibraryArtifact

use of com.google.idea.blaze.base.ideinfo.LibraryArtifact in project intellij by bazelbuild.

the class BlazeAndroidLibrarySource method getLibraries.

@Override
public List<BlazeLibrary> getLibraries() {
    BlazeAndroidSyncData syncData = blazeProjectData.syncState.get(BlazeAndroidSyncData.class);
    if (syncData == null) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<BlazeLibrary> libraries = ImmutableList.builder();
    if (syncData.importResult.resourceLibrary != null) {
        libraries.add(syncData.importResult.resourceLibrary);
    }
    if (syncData.importResult.javacJar != null) {
        libraries.add(new BlazeJarLibrary(new LibraryArtifact(null, syncData.importResult.javacJar, ImmutableList.of())));
    }
    libraries.addAll(syncData.importResult.aarLibraries);
    return libraries.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) BlazeAndroidSyncData(com.google.idea.blaze.android.sync.model.BlazeAndroidSyncData) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact)

Example 12 with LibraryArtifact

use of com.google.idea.blaze.base.ideinfo.LibraryArtifact in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporter method addProtoLegacyLibrariesFromDirectDepsForFlavor.

private void addProtoLegacyLibrariesFromDirectDepsForFlavor(TargetMap targetMap, ProtoLibraryLegacyInfo.ApiFlavor apiFlavor, List<TargetKey> targetKeys, Map<LibraryKey, BlazeJarLibrary> result) {
    for (TargetKey key : targetKeys) {
        TargetIdeInfo target = targetMap.get(key);
        if (target == null) {
            continue;
        }
        ProtoLibraryLegacyInfo protoLibraryLegacyInfo = target.protoLibraryLegacyInfo;
        if (protoLibraryLegacyInfo == null) {
            continue;
        }
        final Collection<LibraryArtifact> libraries;
        switch(apiFlavor) {
            case VERSION_1:
                libraries = protoLibraryLegacyInfo.jarsV1;
                break;
            case MUTABLE:
                libraries = protoLibraryLegacyInfo.jarsMutable;
                break;
            case IMMUTABLE:
                libraries = protoLibraryLegacyInfo.jarsImmutable;
                break;
            default:
                // Can't happen
                libraries = null;
                break;
        }
        if (libraries != null) {
            for (LibraryArtifact libraryArtifact : libraries) {
                BlazeJarLibrary library = new BlazeJarLibrary(libraryArtifact);
                result.put(library.key, library);
            }
        }
    }
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) ProtoLibraryLegacyInfo(com.google.idea.blaze.base.ideinfo.ProtoLibraryLegacyInfo)

Example 13 with LibraryArtifact

use of com.google.idea.blaze.base.ideinfo.LibraryArtifact in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporter method addTargetAsSource.

private void addTargetAsSource(WorkspaceBuilder workspaceBuilder, TargetIdeInfo target, Collection<ArtifactLocation> javaSources) {
    JavaIdeInfo javaIdeInfo = target.javaIdeInfo;
    if (javaIdeInfo == null) {
        return;
    }
    TargetKey targetKey = target.key;
    Collection<String> jars = jdepsMap.getDependenciesForTarget(targetKey);
    if (jars != null) {
        workspaceBuilder.jdeps.addAll(jars);
    }
    // Add all deps if this rule is in the current working set
    if (workingSet == null || workingSet.isTargetInWorkingSet(target)) {
        // Add self, so we pick up our own gen jars if in working set
        workspaceBuilder.directDeps.add(targetKey);
        for (Dependency dep : target.dependencies) {
            if (dep.dependencyType != DependencyType.COMPILE_TIME) {
                continue;
            }
            // forward deps from java proto_library aspect targets
            TargetIdeInfo depTarget = targetMap.get(dep.targetKey);
            if (depTarget != null && Kind.JAVA_PROTO_LIBRARY_KINDS.contains(depTarget.kind)) {
                workspaceBuilder.directDeps.addAll(depTarget.dependencies.stream().map(d -> d.targetKey).collect(Collectors.toList()));
            } else {
                workspaceBuilder.directDeps.add(dep.targetKey);
            }
        }
    }
    for (ArtifactLocation artifactLocation : javaSources) {
        if (artifactLocation.isSource()) {
            duplicateSourceDetector.add(targetKey, artifactLocation);
            workspaceBuilder.sourceArtifacts.add(new SourceArtifact(targetKey, artifactLocation));
            workspaceBuilder.addedSourceFiles.add(artifactLocation);
        }
    }
    ArtifactLocation manifest = javaIdeInfo.packageManifest;
    if (manifest != null) {
        workspaceBuilder.javaPackageManifests.put(targetKey, manifest);
    }
    for (LibraryArtifact libraryArtifact : javaIdeInfo.jars) {
        ArtifactLocation classJar = libraryArtifact.classJar;
        if (classJar != null) {
            workspaceBuilder.buildOutputJars.add(classJar);
        }
    }
    workspaceBuilder.generatedJarsFromSourceTargets.addAll(javaIdeInfo.generatedJars.stream().map(BlazeJarLibrary::new).collect(Collectors.toList()));
    if (javaIdeInfo.filteredGenJar != null) {
        workspaceBuilder.generatedJarsFromSourceTargets.add(new BlazeJarLibrary(javaIdeInfo.filteredGenJar));
    }
    for (BlazeJavaSyncAugmenter augmenter : augmenters) {
        augmenter.addJarsForSourceTarget(workspaceLanguageSettings, projectViewSet, target, workspaceBuilder.outputJarsFromSourceTargets.get(targetKey), workspaceBuilder.generatedJarsFromSourceTargets);
    }
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) Dependency(com.google.idea.blaze.base.ideinfo.Dependency) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact)

Example 14 with LibraryArtifact

use of com.google.idea.blaze.base.ideinfo.LibraryArtifact in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporter method addLibraryToJdeps.

private void addLibraryToJdeps(Map<String, BlazeJarLibrary> jdepsPathToLibrary, BlazeJarLibrary library) {
    LibraryArtifact libraryArtifact = library.libraryArtifact;
    ArtifactLocation interfaceJar = libraryArtifact.interfaceJar;
    if (interfaceJar != null) {
        jdepsPathToLibrary.put(interfaceJar.getExecutionRootRelativePath(), library);
    }
    ArtifactLocation classJar = libraryArtifact.classJar;
    if (classJar != null) {
        jdepsPathToLibrary.put(classJar.getExecutionRootRelativePath(), library);
    }
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact)

Aggregations

LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)14 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)9 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)7 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)6 ImmutableList (com.google.common.collect.ImmutableList)5 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)4 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)4 AndroidIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidIdeInfo)3 JavaIdeInfo (com.google.idea.blaze.base.ideinfo.JavaIdeInfo)3 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)3 Nullable (javax.annotation.Nullable)3 AndroidResourceModuleRegistry (com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry)2 ProtoLibraryLegacyInfo (com.google.idea.blaze.base.ideinfo.ProtoLibraryLegacyInfo)2 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 BlazeJavaSyncAugmenter (com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2