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());
}
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");
}
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");
}
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");
}
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()));
}
}
}
Aggregations