use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testMultipleImportOfJarsGetMerged.
@Test
public void testMultipleImportOfJarsGetMerged() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("lib")))).build();
TargetMapBuilder response = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//lib:libsource").setBuildFile(source("lib/BUILD")).setKind("java_library").addSource(source("lib/Source.java")).setJavaInfo(JavaIdeInfo.builder()).addDependency("//lib:lib0").addDependency("//lib:lib1")).addTarget(TargetIdeInfo.builder().setLabel("//lib:lib0").setBuildFile(source("lib/BUILD")).setKind("java_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(source("lib/lib.jar")).setClassJar(source("lib/lib.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//lib:lib1").setBuildFile(source("lib/BUILD")).setKind("java_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(source("lib/lib.jar")).setClassJar(source("lib/lib.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, response, projectView);
errorCollector.assertNoIssues();
// The libraries were merged
assertThat(result.libraries).hasSize(1);
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testSyncAugmenter.
@Test
public void testSyncAugmenter() {
augmenters.registerExtension((workspaceLanguageSettings, projectViewSet, target, jars, genJars) -> {
if (target.key.label.equals(Label.create("//java/example:source"))) {
jars.add(new BlazeJarLibrary(LibraryArtifact.builder().setInterfaceJar(gen("source.jar")).build()));
}
});
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/example")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/example:source").setBuildFile(source("java/example/BUILD")).setKind("java_library").addSource(source("Source.java")).addDependency("//java/lib:lib").setJavaInfo(JavaIdeInfo.builder())).addTarget(TargetIdeInfo.builder().setLabel("//java/lib:lib").setBuildFile(source("java/lib/BUILD")).setKind("java_library").addSource(source("Lib.java")).setJavaInfo(JavaIdeInfo.builder()));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
assertThat(result.libraries.values().stream().map(BlazeJavaWorkspaceImporterTest::libraryFileName).collect(Collectors.toList())).containsExactly("source.jar");
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testGeneratedLibrariesIncluded.
@Test
public void testGeneratedLibrariesIncluded() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/example")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/example:lib").setBuildFile(source("java/example/BUILD")).setKind("java_library").addSource(source("java/example/Test.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/example/lib-ijar.jar")).setClassJar(gen("java/example/lib.jar"))).addGeneratedJar(LibraryArtifact.builder().setInterfaceJar(gen("java/example/lib-gen.jar")).setClassJar(gen("java/example/lib-gen.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
assertThat(result.libraries.values().stream().map(BlazeJavaWorkspaceImporterTest::libraryFileName).collect(Collectors.toList())).containsExactly("lib-gen.jar");
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testLibraryDependenciesWithJdepsReportingNothingShouldStillIncludeDirectDepsIfInWorkingSet.
@Test
public void testLibraryDependenciesWithJdepsReportingNothingShouldStillIncludeDirectDepsIfInWorkingSet() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("javatests/apps/example")))).build();
TargetMapBuilder targetMapBuilder = targetMapForJdepsSuite();
workingSet = new JavaWorkingSet(workspaceRoot, new WorkingSet(ImmutableList.of(new WorkspacePath("java/apps/example/Test.java")), ImmutableList.of(), ImmutableList.of()), Predicate.isEqual("BUILD"));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
assertThat(result.libraries.values().stream().map(BlazeJavaWorkspaceImporterTest::libraryFileName).collect(Collectors.toList())).containsExactly("a.jar");
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testExcludeTargetTag.
/*
* Test the intellij-exclude-target tag
*/
@Test
public void testExcludeTargetTag() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/apps/example")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example:example").addTag(Tags.TARGET_TAG_EXCLUDE_TARGET).setBuildFile(source("java/apps/example/BUILD")).setKind("java_library").addSource(source("java/apps/example/Example.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("example.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
assertThat(result.javaSourceFiles).isEmpty();
}
Aggregations