use of com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap 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()));
}
use of com.google.idea.blaze.android.sync.importer.aggregators.TransitiveResourceMap in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporter method addSourceTarget.
private void addSourceTarget(WorkspaceBuilder workspaceBuilder, TransitiveResourceMap transitiveResourceMap, TargetIdeInfo target) {
AndroidIdeInfo androidIdeInfo = target.androidIdeInfo;
assert androidIdeInfo != null;
if (shouldGenerateResources(androidIdeInfo) && shouldGenerateResourceModule(androidIdeInfo, whitelistedGenResourcePaths)) {
AndroidResourceModule.Builder builder = new AndroidResourceModule.Builder(target.key);
workspaceBuilder.androidResourceModules.add(builder);
for (ArtifactLocation artifactLocation : androidIdeInfo.resources) {
if (artifactLocation.isSource()) {
builder.addResource(artifactLocation);
} else {
workspaceBuilder.generatedResourceLocations.add(artifactLocation);
if (whitelistedGenResourcePaths.contains(artifactLocation.relativePath)) {
// Still track location in generatedResourceLocations, so that we can warn if a
// whitelist entry goes unused and can be removed.
builder.addResource(artifactLocation);
}
}
}
TransitiveResourceMap.TransitiveResourceInfo transitiveResourceInfo = transitiveResourceMap.get(target.key);
for (ArtifactLocation artifactLocation : transitiveResourceInfo.transitiveResources) {
if (artifactLocation.isSource()) {
builder.addTransitiveResource(artifactLocation);
} else {
workspaceBuilder.generatedResourceLocations.add(artifactLocation);
if (whitelistedGenResourcePaths.contains(artifactLocation.relativePath)) {
builder.addTransitiveResource(artifactLocation);
}
}
}
for (TargetKey resourceDependency : transitiveResourceInfo.transitiveResourceTargets) {
if (!resourceDependency.equals(target.key)) {
builder.addTransitiveResourceDependency(resourceDependency);
}
}
}
}
Aggregations