use of com.google.idea.blaze.android.projectview.GenfilesPath in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testMixingGeneratedAndNonGeneratedSourcesPartlyWhitelisted.
@Test
public void testMixingGeneratedAndNonGeneratedSourcesPartlyWhitelisted() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/example"))).add(DirectoryEntry.include(new WorkspacePath("java/example2"))).add(DirectoryEntry.include(new WorkspacePath("java/uninterestingdir")))).add(ListSection.builder(GeneratedAndroidResourcesSection.KEY).add(new GenfilesPath("java/example/res")).add(new GenfilesPath("unused/whitelisted/path/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()).addTarget(TargetIdeInfo.builder().setLabel("//java/example2:lib").setBuildFile(source("java/example2/BUILD")).setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example2/AndroidManifest.xml")).addResource(source("java/example2/res")).addResource(gen("java/example2/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.example2")).build()).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());
importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertIssues("Dropping 1 generated resource directories.\n" + "R classes will not contain resources from these directories.\n" + "Double-click to add to project view if needed to resolve references.", "Dropping generated resource directory " + String.format("'%s/java/example2/res'", FAKE_GEN_ROOT_EXECUTION_PATH_FRAGMENT) + " w/ 2 subdirs", "1 unused entries in project view section \"generated_android_resource_directories\":\n" + "unused/whitelisted/path/res");
}
use of com.google.idea.blaze.android.projectview.GenfilesPath in project intellij by bazelbuild.
the class AddGeneratedResourceDirectoryNavigatable method addDirectoryToProjectView.
private static void addDirectoryToProjectView(Project project, File projectViewFile, ArtifactLocation generatedResDir) {
ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
ListSection<GenfilesPath> existingSection = builder.getLast(GeneratedAndroidResourcesSection.KEY);
ListSection.Builder<GenfilesPath> directoryBuilder = ListSection.update(GeneratedAndroidResourcesSection.KEY, existingSection);
directoryBuilder.add(new GenfilesPath(generatedResDir.getRelativePath()));
builder.replace(existingSection, directoryBuilder);
return true;
});
if (edit == null) {
Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
return;
}
edit.apply();
VirtualFile projectView = VfsUtil.findFileByIoFile(projectViewFile, false);
if (projectView != null) {
FileEditorManager.getInstance(project).openEditor(new OpenFileDescriptor(project, projectView), true);
}
}
use of com.google.idea.blaze.android.projectview.GenfilesPath 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());
}
Aggregations