use of com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testMixingGeneratedAndNonGeneratedSourcesNoInterestingDirectories.
@Test
public void testMixingGeneratedAndNonGeneratedSourcesNoInterestingDirectories() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/uninterestingdir")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/uninterestingdir:lib").setBuildFile(source("java/uninterestingdir/BUILD")).setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/uninterestingdir/AndroidManifest.xml")).addResource(source("java/uninterestingdir/res")).addResource(gen("java/uninterestingdir/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.uninterestingdir")).build());
BlazeAndroidImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
assertThat(result.androidResourceModules).containsExactly(AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/uninterestingdir:lib"))).addResourceAndTransitiveResource(source("java/uninterestingdir/res")).build());
}
use of com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testConflictingResourceRClasses.
@Test
public void testConflictingResourceRClasses() {
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("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example/AndroidManifest.xml")).addResource(source("java/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.example")).addDependency("//java/example2:resources").build()).addTarget(TargetIdeInfo.builder().setLabel("//java/example:lib2").setBuildFile(source("java/example2/BUILD")).setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example2/AndroidManifest.xml")).addResource(source("java/example/res2")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.example")).build());
BlazeAndroidImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertIssueContaining("Multiple R classes generated");
assertThat(result.androidResourceModules).containsExactly(AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/example:lib"))).addResourceAndTransitiveResource(source("java/example/res")).build());
}
use of com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testMixingGeneratedAndNonGeneratedSourcesWhitelisted.
@Test
public void testMixingGeneratedAndNonGeneratedSourcesWhitelisted() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/example")))).add(ListSection.builder(GeneratedAndroidResourcesSection.KEY).add(new GenfilesPath("java/example/res"))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/example:lib").setBuildFile(source("java/example/BUILD")).setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example/AndroidManifest.xml")).addResource(source("java/example/res")).addResource(gen("java/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.example")).build());
BlazeAndroidImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
assertThat(result.androidResourceModules).containsExactly(AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/example:lib"))).addResourceAndTransitiveResource(source("java/example/res")).addResourceAndTransitiveResource(gen("java/example/res")).build());
}
use of com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testAarImport_outsideSourcesAndNoJdeps_keepsAarLibrary.
@Test
public void testAarImport_outsideSourcesAndNoJdeps_keepsAarLibrary() {
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(Kind.ANDROID_LIBRARY).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example/AndroidManifest.xml")).addResource(source("java/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("example")).setJavaInfo(JavaIdeInfo.builder()).addSource(source("java/example/Source.java")).addDependency("//third_party/lib:an_aar").build()).addTarget(TargetIdeInfo.builder().setLabel("//third_party/lib:an_aar").setBuildFile(source("third_party/lib/BUILD")).setKind(Kind.AAR_IMPORT).setAndroidAarInfo(new AndroidAarIdeInfo(source("third_party/lib/lib_aar.aar"))).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setClassJar(gen("third_party/lib/_aar/an_aar/" + "classes_and_libs_merged.jar")))).build());
BlazeJavaImportResult javaResult = importJavaWorkspace(workspaceRoot, targetMapBuilder, projectView);
BlazeAndroidImportResult androidResult = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
// The java importer performs jdeps optimization, but the android one does not.
assertThat(javaResult.libraries).isEmpty();
assertThat(androidResult.aarLibraries.stream().map(BlazeAndroidWorkspaceImporterTest::aarName).collect(Collectors.toList())).containsExactly("lib_aar.aar");
}
use of com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testResourceInheritance.
/**
* Test that a two packages use the same un-imported android_library
*/
@Test
public void testResourceInheritance() {
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();
/**
* Deps are project -> lib0 -> lib1 -> shared project -> shared
*/
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example/lib0:lib0").setKind("android_library").setBuildFile(source("java/apps/example/lib0/BUILD")).addSource(source("java/apps/example/lib0/SharedActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/apps/example/lib0/AndroidManifest.xml")).addResource(source("java/apps/example/lib0/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.apps.example.lib0")).addDependency("//java/apps/example/lib1:lib1").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/apps/example/lib0/lib0.jar")).setClassJar(gen("java/apps/example/lib0/lib0.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example/lib1:lib1").setKind("android_library").setBuildFile(source("java/apps/example/lib1/BUILD")).addSource(source("java/apps/example/lib1/SharedActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/apps/example/lib1/AndroidManifest.xml")).addResource(source("java/apps/example/lib1/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.apps.example.lib1")).addDependency("//java/libraries/shared:shared").setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/apps/example/lib1/lib1.jar")).setClassJar(gen("java/apps/example/lib1/lib1.jar"))))).addTarget(TargetIdeInfo.builder().setLabel("//java/apps/example:example_debug").setKind("android_binary").setBuildFile(source("java/apps/example/BUILD")).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/apps/example/lib0:lib0").addDependency("//java/libraries/shared:shared").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/shared:shared").setBuildFile(source("java/libraries/shared/BUILD")).setKind("android_library").addSource(source("java/libraries/shared/SharedActivity.java")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/libraries/shared/AndroidManifest.xml")).addResource(source("java/libraries/shared/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.libraries.shared")).setBuildFile(source("java/libraries/shared/BUILD")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("java/libraries/shared.jar")).setClassJar(gen("java/libraries/shared.jar")))));
BlazeAndroidImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
assertThat(result.androidResourceModules).containsExactly(AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/apps/example:example_debug"))).addResourceAndTransitiveResource(source("java/apps/example/res")).addTransitiveResource(source("java/apps/example/lib0/res")).addTransitiveResource(source("java/apps/example/lib1/res")).addTransitiveResource(source("java/libraries/shared/res")).addTransitiveResourceDependency("//java/apps/example/lib0:lib0").addTransitiveResourceDependency("//java/apps/example/lib1:lib1").addTransitiveResourceDependency("//java/libraries/shared:shared").build(), AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/apps/example/lib0:lib0"))).addResourceAndTransitiveResource(source("java/apps/example/lib0/res")).addTransitiveResource(source("java/apps/example/lib1/res")).addTransitiveResource(source("java/libraries/shared/res")).addTransitiveResourceDependency("//java/apps/example/lib1:lib1").addTransitiveResourceDependency("//java/libraries/shared:shared").build(), AndroidResourceModule.builder(TargetKey.forPlainTarget(Label.create("//java/apps/example/lib1:lib1"))).addResourceAndTransitiveResource(source("java/apps/example/lib1/res")).addTransitiveResource(source("java/libraries/shared/res")).addTransitiveResourceDependency("//java/libraries/shared:shared").build());
}
Aggregations