Search in sources :

Example 36 with ArtifactLocation

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

the class BlazeRenderErrorContributor method reportGeneratedResources.

/**
 * We can't find generated resources. If a layout uses them, the layout won't render correctly.
 */
private void reportGeneratedResources(AndroidResourceModule resourceModule, TargetMap targetMap, ArtifactLocationDecoder decoder) {
    Map<String, Throwable> brokenClasses = logger.getBrokenClasses();
    if (brokenClasses == null || brokenClasses.isEmpty()) {
        return;
    }
    // Sorted entries for deterministic error message.
    SortedMap<ArtifactLocation, TargetIdeInfo> generatedResources = Maps.newTreeMap(getGeneratedResources(targetMap.get(resourceModule.targetKey)));
    for (TargetKey dependency : resourceModule.transitiveResourceDependencies) {
        generatedResources.putAll(getGeneratedResources(targetMap.get(dependency)));
    }
    if (generatedResources.isEmpty()) {
        return;
    }
    HtmlBuilder builder = new HtmlBuilder();
    builder.add("Generated resources will not be discovered by the IDE:");
    builder.beginList();
    for (Map.Entry<ArtifactLocation, TargetIdeInfo> entry : generatedResources.entrySet()) {
        ArtifactLocation resource = entry.getKey();
        TargetIdeInfo target = entry.getValue();
        builder.listItem().add(resource.getRelativePath()).add(" from ");
        addTargetLink(builder, target, decoder);
    }
    builder.endList().add("Please avoid using generated resources, ").addLink("then ", "sync the project", " ", getLinkManager().createSyncProjectUrl()).addLink("and ", "refresh the layout", ".", getLinkManager().createRefreshRenderUrl());
    addIssue().setSeverity(HighlightSeverity.ERROR, // Reported above broken classes
    HIGH_PRIORITY + 1).setSummary("Generated resources").setHtmlContent(builder).build();
}
Also used : TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) HtmlBuilder(com.android.utils.HtmlBuilder) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) Map(java.util.Map) TransitiveDependencyMap(com.google.idea.blaze.base.targetmaps.TransitiveDependencyMap) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) SortedMap(java.util.SortedMap)

Example 37 with ArtifactLocation

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

the class ArtifactLocationDecoderTest method testGeneratedArtifact.

@Test
public void testGeneratedArtifact() throws Exception {
    ArtifactLocation artifactLocation = ArtifactLocation.builder().setRootExecutionPathFragment("/blaze-out/bin").setRelativePath("com/google/Bla.java").setIsSource(false).build();
    ArtifactLocationDecoder decoder = new ArtifactLocationDecoderImpl(BlazeInfo.createMockBlazeInfo(OUTPUT_BASE, EXECUTION_ROOT, EXECUTION_ROOT + "/blaze-out/crosstool/bin", EXECUTION_ROOT + "/blaze-out/crosstool/genfiles"), null);
    assertThat(decoder.decode(artifactLocation).getPath()).isEqualTo(EXECUTION_ROOT + "/blaze-out/bin/com/google/Bla.java");
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Test(org.junit.Test)

Example 38 with ArtifactLocation

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

the class ArtifactLocationDecoderTest method testExternalDerivedArtifactOldFormat.

@Test
public void testExternalDerivedArtifactOldFormat() throws Exception {
    ArtifactLocation artifactLocation = IdeInfoFromProtobuf.makeArtifactLocation(IntellijIdeInfo.ArtifactLocation.newBuilder().setRelativePath("external/repo_name/com/google/Bla.java").setRootExecutionPathFragment("blaze-out/crosstool/bin").setIsSource(false).setIsExternal(true).build());
    assertThat(artifactLocation.getRelativePath()).isEqualTo("com/google/Bla.java");
    assertThat(artifactLocation.getExecutionRootRelativePath()).isEqualTo("blaze-out/crosstool/bin/external/repo_name/com/google/Bla.java");
    ArtifactLocationDecoder decoder = new ArtifactLocationDecoderImpl(BlazeInfo.createMockBlazeInfo(OUTPUT_BASE, EXECUTION_ROOT, EXECUTION_ROOT + "/blaze-out/crosstool/bin", EXECUTION_ROOT + "/blaze-out/crosstool/genfiles"), null);
    assertThat(decoder.decode(artifactLocation).getPath()).isEqualTo(EXECUTION_ROOT + "/blaze-out/crosstool/bin/external/repo_name/com/google/Bla.java");
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Test(org.junit.Test)

Example 39 with ArtifactLocation

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

the class IdeInfoFromProtobuf method makeTargetIdeInfo.

@Nullable
public static TargetIdeInfo makeTargetIdeInfo(IntellijIdeInfo.TargetIdeInfo message) {
    Kind kind = getKind(message);
    if (kind == null) {
        return null;
    }
    TargetKey key = getKey(message);
    ArtifactLocation buildFile = getBuildFile(message);
    final Collection<Dependency> dependencies;
    if (message.getDepsCount() > 0) {
        dependencies = message.getDepsList().stream().map(IdeInfoFromProtobuf::makeDependency).collect(toList());
    } else {
        dependencies = Lists.newArrayListWithCapacity(message.getDependenciesCount() + message.getRuntimeDepsCount());
        dependencies.addAll(makeDependencyListFromLabelList(message.getDependenciesList(), DependencyType.COMPILE_TIME));
        dependencies.addAll(makeDependencyListFromLabelList(message.getRuntimeDepsList(), DependencyType.RUNTIME));
    }
    Collection<String> tags = ImmutableList.copyOf(message.getTagsList());
    Collection<ArtifactLocation> sources = Lists.newArrayList();
    CIdeInfo cIdeInfo = null;
    if (message.hasCIdeInfo()) {
        cIdeInfo = makeCIdeInfo(message.getCIdeInfo());
        sources.addAll(cIdeInfo.sources);
        sources.addAll(cIdeInfo.headers);
        sources.addAll(cIdeInfo.textualHeaders);
    }
    CToolchainIdeInfo cToolchainIdeInfo = null;
    if (message.hasCToolchainIdeInfo()) {
        cToolchainIdeInfo = makeCToolchainIdeInfo(message.getCToolchainIdeInfo());
    }
    JavaIdeInfo javaIdeInfo = null;
    if (message.hasJavaIdeInfo()) {
        javaIdeInfo = makeJavaIdeInfo(message.getJavaIdeInfo());
        Collection<ArtifactLocation> javaSources = makeArtifactLocationList(message.getJavaIdeInfo().getSourcesList());
        sources.addAll(javaSources);
    }
    AndroidIdeInfo androidIdeInfo = null;
    if (message.hasAndroidIdeInfo()) {
        androidIdeInfo = makeAndroidIdeInfo(message.getAndroidIdeInfo());
    }
    AndroidSdkIdeInfo androidSdkIdeInfo = null;
    if (message.hasAndroidSdkIdeInfo()) {
        androidSdkIdeInfo = makeAndroidSdkIdeInfo(message.getAndroidSdkIdeInfo());
    }
    AndroidAarIdeInfo androidAarIdeInfo = null;
    if (message.hasAndroidAarIdeInfo()) {
        androidAarIdeInfo = makeAndroidAarIdeInfo(message.getAndroidAarIdeInfo());
    }
    PyIdeInfo pyIdeInfo = null;
    if (message.hasPyIdeInfo()) {
        pyIdeInfo = makePyIdeInfo(message.getPyIdeInfo());
        sources.addAll(pyIdeInfo.sources);
    }
    GoIdeInfo goIdeInfo = null;
    if (message.hasGoIdeInfo()) {
        goIdeInfo = makeGoIdeInfo(message.getGoIdeInfo());
        sources.addAll(goIdeInfo.sources);
    }
    JsIdeInfo jsIdeInfo = null;
    if (message.hasJsIdeInfo()) {
        jsIdeInfo = makeJsIdeInfo(message.getJsIdeInfo());
        sources.addAll(jsIdeInfo.sources);
    }
    TsIdeInfo tsIdeInfo = null;
    if (message.hasTsIdeInfo()) {
        tsIdeInfo = makeTsIdeInfo(message.getTsIdeInfo());
        sources.addAll(tsIdeInfo.sources);
    }
    DartIdeInfo dartIdeInfo = null;
    if (message.hasDartIdeInfo()) {
        dartIdeInfo = makeDartIdeInfo(message.getDartIdeInfo());
        sources.addAll(dartIdeInfo.sources);
    }
    TestIdeInfo testIdeInfo = null;
    if (message.hasTestInfo()) {
        testIdeInfo = makeTestIdeInfo(message.getTestInfo());
    }
    ProtoLibraryLegacyInfo protoLibraryLegacyInfo = null;
    if (message.hasProtoLibraryLegacyJavaIdeInfo()) {
        protoLibraryLegacyInfo = makeProtoLibraryLegacyInfo(message.getProtoLibraryLegacyJavaIdeInfo());
    }
    JavaToolchainIdeInfo javaToolchainIdeInfo = null;
    if (message.hasJavaToolchainIdeInfo()) {
        javaToolchainIdeInfo = makeJavaToolchainIdeInfo(message.getJavaToolchainIdeInfo());
    }
    return new TargetIdeInfo(key, kind, buildFile, dependencies, tags, sources, cIdeInfo, cToolchainIdeInfo, javaIdeInfo, androidIdeInfo, androidSdkIdeInfo, androidAarIdeInfo, pyIdeInfo, goIdeInfo, jsIdeInfo, tsIdeInfo, dartIdeInfo, testIdeInfo, protoLibraryLegacyInfo, javaToolchainIdeInfo);
}
Also used : TsIdeInfo(com.google.idea.blaze.base.ideinfo.TsIdeInfo) PyIdeInfo(com.google.idea.blaze.base.ideinfo.PyIdeInfo) JsIdeInfo(com.google.idea.blaze.base.ideinfo.JsIdeInfo) GoIdeInfo(com.google.idea.blaze.base.ideinfo.GoIdeInfo) Dependency(com.google.idea.blaze.base.ideinfo.Dependency) DartIdeInfo(com.google.idea.blaze.base.ideinfo.DartIdeInfo) TestIdeInfo(com.google.idea.blaze.base.ideinfo.TestIdeInfo) ProtoLibraryLegacyInfo(com.google.idea.blaze.base.ideinfo.ProtoLibraryLegacyInfo) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) JavaToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.JavaToolchainIdeInfo) CToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.CToolchainIdeInfo) AndroidAarIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo) Kind(com.google.idea.blaze.base.model.primitives.Kind) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) CIdeInfo(com.google.idea.blaze.base.ideinfo.CIdeInfo) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) AndroidSdkIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo) Nullable(javax.annotation.Nullable)

Aggregations

ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)39 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)13 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)10 File (java.io.File)10 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)9 Test (org.junit.Test)9 JavaIdeInfo (com.google.idea.blaze.base.ideinfo.JavaIdeInfo)8 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)8 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)8 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)8 Nullable (javax.annotation.Nullable)8 ImmutableList (com.google.common.collect.ImmutableList)7 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)7 List (java.util.List)7 Label (com.google.idea.blaze.base.model.primitives.Label)6 Lists (com.google.common.collect.Lists)5 AndroidResourceModule (com.google.idea.blaze.android.sync.model.AndroidResourceModule)5 SourceToTargetMap (com.google.idea.blaze.base.targetmaps.SourceToTargetMap)5 Map (java.util.Map)5 ImmutableSet (com.google.common.collect.ImmutableSet)4