use of com.google.idea.blaze.base.projectview.ProjectView 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.projectview.ProjectView 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.projectview.ProjectView 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.projectview.ProjectView 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();
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testNormalJavaLibraryPackage.
/*
* Test that the non-android libraries can be imported.
*/
@Test
public void testNormalJavaLibraryPackage() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/apps/example"))).add(DirectoryEntry.include(new WorkspacePath("java/library/something")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example:example_debug").setBuildFile(source("java/apps/example/BUILD")).setKind("android_binary").addSource(source("java/apps/example/MainActivity.java")).addSource(source("java/apps/example/subdir/SubdirHelper.java")).setJavaInfo(JavaIdeInfo.builder()).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/apps/example/AndroidManifest.xml")).addResource(source("java/apps/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.apps.example")).addDependency("//java/library/something:something")).addTarget(TargetIdeInfo.builder().setLabel("//java/library/something:something").setBuildFile(source("java/library/something/BUILD")).setKind("java_library").addSource(source("java/library/something/SomeJavaFile.java")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/library/something/something.jar")).setClassJar(gen("java/library/something/something.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
assertThat(result.contentEntries).containsExactly(BlazeContentEntry.builder("/root/java/apps/example").addSource(BlazeSourceDirectory.builder("/root/java/apps/example").setPackagePrefix("apps.example").build()).build(), BlazeContentEntry.builder("/root/java/library/something").addSource(BlazeSourceDirectory.builder("/root/java/library/something").setPackagePrefix("library.something").build()).build());
}
Aggregations