use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testScalaBinaryWithMultipleLibraries.
@Test
public void testScalaBinaryWithMultipleLibraries() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/some/library1:library1").addDependency("//src/main/java/other/library2:library2")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/some/library1:library1").setBuildFile(source("src/main/scala/some/library1/BUILD")).setKind("scala_library").addSource(source("src/main/scala/some/library1/Library.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/some/library1/library1_ijar.jar")).setClassJar(gen("src/main/scala/some/library1/library1.jar")))).addDependency("//src/main/java/other/import:import")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/java/other/library2:library2").setBuildFile(source("src/main/java/other/library2/BUILD")).setKind("java_library").addSource(source("src/main/java/other/library2/Library.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/java/other/library2/liblibrary2-ijar.jar")).setClassJar(gen("src/main/java/other/library2/liblibrary2.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//src/main/java/other/import:import").setBuildFile(source("src/main/java/other/import/BUILD")).setKind("java_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/java/other/import/libimport-ijar.jar")).setClassJar(gen("src/main/java/other/import/libimport.jar"))))).build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build());
// Direct library deps will be double counted.
assertThat(javaImportResult.libraries).hasSize(2);
assertThat(hasLibrary(javaImportResult.libraries, "library1_ijar")).isTrue();
assertThat(hasLibrary(javaImportResult.libraries, "library2-ijar")).isTrue();
assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"));
assertThat(scalaImportResult.libraries).hasSize(3);
assertThat(hasLibrary(scalaImportResult.libraries, "library1_ijar")).isTrue();
assertThat(hasLibrary(scalaImportResult.libraries, "library2-ijar")).isTrue();
assertThat(hasLibrary(scalaImportResult.libraries, "import-ijar")).isTrue();
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testSourceTargetsWithoutNonGeneratedSourcesAddedToLibraries.
@Test
public void testSourceTargetsWithoutNonGeneratedSourcesAddedToLibraries() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/some/library")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/some/library:library")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/some/library:library").setBuildFile(source("src/main/scala/some/library/BUILD")).setKind("scala_library").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/some/library/library_ijar.jar")).setClassJar(gen("src/main/scala/some/library/library.jar"))))).build();
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(scalaImportResult.libraries).hasSize(1);
assertThat(hasLibrary(scalaImportResult.libraries, "library_ijar")).isTrue();
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testSourceRulesNotInLibraries.
@Test
public void testSourceRulesNotInLibraries() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/some/library1"))).add(DirectoryEntry.include(new WorkspacePath("src/main/java/other/library2")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setBuildFile(source("src/main/scala/apps/example/BUILD")).setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).addSource(source("src/main/scala/apps/example/subdir/SubdirHelper.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/some/library1:library1").addDependency("//src/main/java/other/library2:library2")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/some/library1:library1").setBuildFile(source("src/main/scala/some/library1/BUILD")).setKind("scala_library").addSource(source("src/main/scala/some/library1/Library.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/some/library1/library1_ijar.jar")).setClassJar(gen("src/main/scala/some/library1/library1.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//src/main/java/other/library2:library2").setBuildFile(source("src/main/java/other/library2/BUILD")).setKind("java_library").addSource(source("src/main/java/other/library2/Library.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/java/other/library2/libibrary2-ijar.jar")).setClassJar(gen("src/main/java/other/library2/liblibrary2.jar"))))).build();
BlazeJavaImportResult javaImportResult = importJava(projectView, targetMap);
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(javaImportResult.contentEntries).containsExactly(BlazeContentEntry.builder("/root/src/main/scala/apps/example").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/apps/example").setPackagePrefix("apps.example").build()).build(), BlazeContentEntry.builder("/root/src/main/scala/some/library1").addSource(BlazeSourceDirectory.builder("/root/src/main/scala/some/library1").setPackagePrefix("some.library1").build()).build(), BlazeContentEntry.builder("/root/src/main/java/other/library2").addSource(BlazeSourceDirectory.builder("/root/src/main/java/other/library2").setPackagePrefix("other.library2").build()).build());
assertThat(javaImportResult.libraries).isEmpty();
assertThat(javaImportResult.javaSourceFiles).containsExactly(source("src/main/scala/apps/example/Main.scala"), source("src/main/scala/apps/example/subdir/SubdirHelper.scala"), source("src/main/scala/some/library1/Library.scala"), source("src/main/java/other/library2/Library.java"));
assertThat(scalaImportResult.libraries).isEmpty();
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method testDuplicateScalaLibraries.
@Test
public void testDuplicateScalaLibraries() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("src/main/scala/apps/example")))).build();
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/apps/example:example").setKind("scala_binary").addSource(source("src/main/scala/apps/example/Main.scala")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/apps/example/example.jar")).setClassJar(gen("src/main/scala/apps/example/example.jar")))).addDependency("//src/main/scala/imports:import1").addDependency("//src/main/scala/imports:import2")).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/imports:import1").setKind("scala_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/imports/import.jar")).setClassJar(gen("src/main/scala/imports/import.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//src/main/scala/imports:import2").setKind("scala_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("src/main/scala/imports/import.jar")).setClassJar(gen("src/main/scala/imports/import.jar"))))).build();
BlazeScalaImportResult scalaImportResult = importScala(projectView, targetMap);
errorCollector.assertNoIssues();
assertThat(scalaImportResult.libraries).hasSize(1);
assertThat(hasLibrary(scalaImportResult.libraries, "import")).isTrue();
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method importJava.
private BlazeJavaImportResult importJava(ProjectView projectView, TargetMap targetMap) {
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
WorkspaceLanguageSettings languageSettings = new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.SCALA, LanguageClass.JAVA));
JavaSourceFilter sourceFilter = new JavaSourceFilter(project, workspaceRoot, projectViewSet, targetMap);
JdepsMap jdepsMap = key -> ImmutableList.of();
ArtifactLocationDecoder decoder = location -> new File(location.getRelativePath());
return new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, languageSettings, targetMap, sourceFilter, jdepsMap, null, decoder).importWorkspace(context);
}
Aggregations