Search in sources :

Example 11 with ArtifactLocation

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

the class IdeInfoFromProtobuf method makeLibraryArtifact.

@Nullable
private static LibraryArtifact makeLibraryArtifact(IntellijIdeInfo.LibraryArtifact libraryArtifact) {
    ArtifactLocation classJar = libraryArtifact.hasJar() ? makeArtifactLocation(libraryArtifact.getJar()) : null;
    ArtifactLocation iJar = libraryArtifact.hasInterfaceJar() ? makeArtifactLocation(libraryArtifact.getInterfaceJar()) : null;
    ImmutableList.Builder<ArtifactLocation> sourceJars = ImmutableList.builder();
    if (!libraryArtifact.getSourceJarsList().isEmpty()) {
        sourceJars.addAll(libraryArtifact.getSourceJarsList().stream().map(IdeInfoFromProtobuf::makeArtifactLocation).collect(Collectors.toList()));
    } else if (libraryArtifact.hasSourceJar()) {
        sourceJars.add(makeArtifactLocation(libraryArtifact.getSourceJar()));
    }
    if (iJar == null && classJar == null) {
        // drop invalid ArtifactLocations
        return null;
    }
    return new LibraryArtifact(iJar, classJar, sourceJars.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) Nullable(javax.annotation.Nullable)

Example 12 with ArtifactLocation

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

the class ArtifactLocationDecoderTest method testExternalDerivedArtifactNewFormat.

@Test
public void testExternalDerivedArtifactNewFormat() throws Exception {
    ArtifactLocation artifactLocation = IdeInfoFromProtobuf.makeArtifactLocation(IntellijIdeInfo.ArtifactLocation.newBuilder().setRelativePath("com/google/Bla.java").setRootExecutionPathFragment("../repo_name/blaze-out/crosstool/bin").setIsSource(false).setIsNewExternalVersion(true).build());
    assertThat(artifactLocation.getRelativePath()).isEqualTo("com/google/Bla.java");
    assertThat(artifactLocation.getExecutionRootRelativePath()).isEqualTo("../repo_name/blaze-out/crosstool/bin/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(OUTPUT_BASE + "/execroot/repo_name/blaze-out/crosstool/bin/com/google/Bla.java");
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Test(org.junit.Test)

Example 13 with ArtifactLocation

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

the class ArtifactLocationDecoderTest method testExternalSourceArtifactOldFormat.

@Test
public void testExternalSourceArtifactOldFormat() throws Exception {
    ArtifactLocation artifactLocation = IdeInfoFromProtobuf.makeArtifactLocation(IntellijIdeInfo.ArtifactLocation.newBuilder().setRelativePath("external/repo_name/com/google/Bla.java").setIsSource(true).setIsExternal(true).build());
    assertThat(artifactLocation.getRelativePath()).isEqualTo("com/google/Bla.java");
    assertThat(artifactLocation.getExecutionRootRelativePath()).isEqualTo("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 + "/external/repo_name/com/google/Bla.java");
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Test(org.junit.Test)

Example 14 with ArtifactLocation

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

the class ArtifactLocationDecoderTest method testExternalSourceArtifactNewFormat.

@Test
public void testExternalSourceArtifactNewFormat() throws Exception {
    ArtifactLocation artifactLocation = IdeInfoFromProtobuf.makeArtifactLocation(IntellijIdeInfo.ArtifactLocation.newBuilder().setRelativePath("com/google/Bla.java").setRootExecutionPathFragment("../repo_name").setIsSource(true).setIsExternal(true).setIsNewExternalVersion(true).build());
    assertThat(artifactLocation.getRelativePath()).isEqualTo("com/google/Bla.java");
    assertThat(artifactLocation.getExecutionRootRelativePath()).isEqualTo("../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(OUTPUT_BASE + "/execroot/repo_name/com/google/Bla.java");
}
Also used : ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) Test(org.junit.Test)

Example 15 with ArtifactLocation

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

the class BlazeJavaSyncPlugin method warnAboutDeployJars.

/**
 * Looks at your jars for anything that seems to be a deploy jar and warns about it. This often
 * turns out to be a duplicate copy of all your application's code, so you don't want it in your
 * project.
 */
private static void warnAboutDeployJars(BlazeContext context, BlazeJavaSyncData syncData) {
    for (BlazeLibrary library : syncData.importResult.libraries.values()) {
        if (!(library instanceof BlazeJarLibrary)) {
            continue;
        }
        BlazeJarLibrary jarLibrary = (BlazeJarLibrary) library;
        LibraryArtifact libraryArtifact = jarLibrary.libraryArtifact;
        ArtifactLocation artifactLocation = libraryArtifact.jarForIntellijLibrary();
        if (artifactLocation.getRelativePath().endsWith("deploy.jar") || artifactLocation.getRelativePath().endsWith("deploy-ijar.jar") || artifactLocation.getRelativePath().endsWith("deploy-hjar.jar")) {
            context.output(new PerformanceWarning("Performance warning: You have added a deploy jar as a library. " + "This can lead to poor indexing performance, and the debugger may " + "become confused and step into the deploy jar instead of your code. " + "Consider redoing the rule to not use deploy jars, exclude the target " + "from your .blazeproject, or exclude the library.\n" + "Library path: " + artifactLocation.getRelativePath()));
        }
    }
}
Also used : BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact)

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