Search in sources :

Example 6 with BlazeJavaImportResult

use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 7 with BlazeJavaImportResult

use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 8 with BlazeJavaImportResult

use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Example 9 with BlazeJavaImportResult

use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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");
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) JavaWorkingSet(com.google.idea.blaze.java.sync.workingset.JavaWorkingSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) JavaWorkingSet(com.google.idea.blaze.java.sync.workingset.JavaWorkingSet) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) Test(org.junit.Test)

Example 10 with BlazeJavaImportResult

use of com.google.idea.blaze.java.sync.model.BlazeJavaImportResult 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();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Aggregations

BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)44 Test (org.junit.Test)42 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)39 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)38 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)32 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)7 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)7 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)5 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)5 BlazeContentEntry (com.google.idea.blaze.java.sync.model.BlazeContentEntry)5 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)5 BlazeJavaSyncData (com.google.idea.blaze.java.sync.model.BlazeJavaSyncData)4 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)4 File (java.io.File)4 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)3 Glob (com.google.idea.blaze.base.projectview.section.Glob)3 GlobSet (com.google.idea.blaze.base.projectview.section.Glob.GlobSet)3 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)3 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)2 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)2