use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testLibraryWithSourceJar.
/**
* Test library with a source jar
*/
@Test
public void testLibraryWithSourceJar() {
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 = 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")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/apps/example/AndroidManifest.xml")).addResource(gen("java/apps/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.apps.example")).addDependency("//thirdparty/some/library:library").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/apps/example/example_debug.jar")).setClassJar(gen("java/apps/example/example_debug.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//thirdparty/some/library:library").setBuildFile(source("/thirdparty/some/library/BUILD")).setKind("java_import").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("thirdparty/some/library.jar")).setClassJar(gen("thirdparty/some/library.jar")).addSourceJar(gen("thirdparty/some/library.srcjar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
BlazeJarLibrary library = findLibrary(result.libraries, "library.jar");
assertNotNull(library);
assertThat(library.libraryArtifact.sourceJars).isNotEmpty();
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testJavaTestTarget.
/**
* Test a project with a java test rule
*/
@Test
public void testJavaTestTarget() {
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")))).add(ListSection.builder(TestSourceSection.KEY).add(new Glob("javatests/*"))).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")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/apps/example/AndroidManifest.xml")).addResource(source("java/apps/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.apps.example")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/apps/example/example_debug.jar")).setClassJar(gen("java/apps/example/example_debug.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//javatests/apps/example:example").setBuildFile(source("javatests/apps/example/BUILD")).setKind("java_test").addSource(source("javatests/apps/example/ExampleTests.java")).addDependency("//java/apps/example:example_debug").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("javatests/apps/example/example.jar")).setClassJar(gen("javatests/apps/example/example.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/javatests/apps/example").addSource(BlazeSourceDirectory.builder("/root/javatests/apps/example").setPackagePrefix("apps.example").build()).build());
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testExcludeTarget.
/*
* Test the exclude_target section
*/
@Test
public void testExcludeTarget() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/apps/example")))).add(ListSection.builder(ExcludeTargetSection.KEY).add(Label.create("//java/apps/example:example"))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example:example").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.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testImportAsLibraryTagLegacy.
@Test
public void testImportAsLibraryTagLegacy() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("lib"))).add(DirectoryEntry.include(new WorkspacePath("lib2")))).build();
TargetMapBuilder response = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//lib:lib").setBuildFile(source("lib/BUILD")).setKind("java_library").addSource(source("lib/Lib.java")).addDependency("//lib2:lib2").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("lib/lib.jar")).setClassJar(gen("lib/lib.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//lib2:lib2").setBuildFile(source("lib2/BUILD")).setKind("java_library").addSource(source("lib2/Lib2.java")).addTag("aswb-import-as-library").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("lib2/lib2.jar")).setClassJar(gen("lib2/lib2.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, response, projectView);
errorCollector.assertNoIssues();
assertThat(result.libraries).hasSize(1);
}
use of com.google.idea.blaze.base.ideinfo.TargetMapBuilder in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testTargetWithMixedGeneratedSourcesAddsFilteredGenJar.
@Test
public void testTargetWithMixedGeneratedSourcesAddsFilteredGenJar() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("import")))).build();
TargetMapBuilder response = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//import:lib").setBuildFile(source("import/BUILD")).setKind("java_library").addSource(source("import/Import.java")).addSource(gen("import/Import.java")).setJavaInfo(JavaIdeInfo.builder().setFilteredGenJar(LibraryArtifact.builder().setInterfaceJar(gen("import/filtered-gen.jar")))));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, response, projectView);
errorCollector.assertNoIssues();
assertThat(findLibrary(result.libraries, "filtered-gen.jar")).isNotNull();
}
Aggregations