use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testLibraryDependenciesWithJdepsSet.
@Test
public void testLibraryDependenciesWithJdepsSet() {
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();
jdepsMap.put(TargetKey.forPlainTarget(Label.create("//java/apps/example:example_debug")), Lists.newArrayList(jdepsPath("thirdparty/a.jar"), jdepsPath("thirdparty/c.jar")));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
assertThat(result.libraries.values().stream().map(BlazeJavaWorkspaceImporterTest::libraryFileName).collect(Collectors.toList())).containsExactly("a.jar", "c.jar");
}
use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testLibraryDepsWithJdepsReportingZeroShouldNotIncludeDirectDepsIfNotInWorkingSet.
@Test
public void testLibraryDepsWithJdepsReportingZeroShouldNotIncludeDirectDepsIfNotInWorkingSet() {
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(), ImmutableList.of(), ImmutableList.of()), Predicate.isEqual("BUILD"));
BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
assertThat(result.libraries.values().stream().map(BlazeJavaWorkspaceImporterTest::libraryFileName).collect(Collectors.toList())).isEmpty();
}
use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testProjectAndTests.
/**
* Import a project and its tests
*/
@Test
public void testProjectAndTests() {
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("android_test").addSource(source("javatests/apps/example/ExampleTests.java")).setAndroidInfo(AndroidIdeInfo.builder().setResourceJavaPackage("com.google.android.apps.example")).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.java.sync.model.BlazeJavaImportResult in project intellij by bazelbuild.
the class BlazeJavaWorkspaceImporterTest method testImportFilter.
/**
* Imports two binaries and a library. Only one binary should pass the package filter.
*/
@Test
public void testImportFilter() {
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_debug").setBuildFile(source("java/apps/example/BUILD")).setKind("android_binary").addSource(source("java/apps/example/MainActivity.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")).addDependency("//java/libraries/example: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("//java/libraries/example:example").setBuildFile(source("java/libraries/example/BUILD")).setKind("java_library").addSource(source("java/libraries/example/SharedActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/libraries/example/AndroidManifest.xml")).addResource(source("java/libraries/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.libraries.example")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/libraries/example/example.jar")).setClassJar(gen("java/libraries/example/example.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//java/com/dontimport:example_debug").setBuildFile(source("java/com/dontimport/BUILD")).setKind("android_binary").addSource(source("java/com/dontimport/MainActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/com/dontimport/AndroidManifest.xml")).addResource(source("java/com/dontimport/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.dontimport")).addDependency("//java/com/dontimport:sometarget").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/com/dontimport/example_debug.jar")).setClassJar(gen("java/com/dontimport/example_debug.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());
assertThat(result.javaSourceFiles).containsExactly(source("java/apps/example/MainActivity.java"));
}
use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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();
}
Aggregations