use of com.google.idea.blaze.android.sync.model.BlazeResourceLibrary in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testResourceImportOutsideSourceFilterIsAddedToResourceLibrary.
@Test
public void testResourceImportOutsideSourceFilterIsAddedToResourceLibrary() {
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/example2:resources").setBuildFile(source("java/example2/BUILD")).setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example2/AndroidManifest.xml")).addResource(source("java/example2/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.android.example2")).build());
BlazeAndroidImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
BlazeResourceLibrary library = result.resourceLibrary;
assertThat(library).isNotNull();
assertThat(library.sources).containsExactly(ArtifactLocation.builder().setRelativePath("java/example2/res").setIsSource(true).build());
}
use of com.google.idea.blaze.android.sync.model.BlazeResourceLibrary in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporter method importWorkspace.
public BlazeAndroidImportResult importWorkspace() {
List<TargetIdeInfo> sourceTargets = targetMap.targets().stream().filter(target -> target.kind.languageClass == LanguageClass.ANDROID).filter(target -> target.androidIdeInfo != null).filter(importFilter::isSourceTarget).filter(target -> !importFilter.excludeTarget(target)).collect(Collectors.toList());
TransitiveResourceMap transitiveResourceMap = new TransitiveResourceMap(targetMap);
WorkspaceBuilder workspaceBuilder = new WorkspaceBuilder();
for (TargetIdeInfo target : sourceTargets) {
addSourceTarget(workspaceBuilder, transitiveResourceMap, target);
}
GeneratedResourceWarnings.submit(project, context, projectViewSet, artifactLocationDecoder, workspaceBuilder.generatedResourceLocations, whitelistedGenResourcePaths);
ImmutableList<AndroidResourceModule> androidResourceModules = buildAndroidResourceModules(workspaceBuilder);
BlazeResourceLibrary resourceLibrary = createResourceLibrary(androidResourceModules);
ImmutableList<AarLibrary> aarLibraries = createAarLibraries(sourceFilter.getLibraryTargets());
return new BlazeAndroidImportResult(androidResourceModules, resourceLibrary, aarLibraries, getJavacJar(targetMap.targets()));
}
Aggregations