use of com.google.idea.blaze.android.sync.model.AarLibrary in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporter method createAarLibraries.
private ImmutableList<AarLibrary> createAarLibraries(Iterable<TargetIdeInfo> libraryTargets) {
ImmutableList.Builder<AarLibrary> builder = ImmutableList.builder();
for (TargetIdeInfo target : libraryTargets) {
// don't have the equivalent of jdeps data.
if (target.androidAarIdeInfo == null || target.javaIdeInfo == null || target.javaIdeInfo.jars.isEmpty()) {
continue;
}
// aar_import should only have one jar (a merged jar from the AAR's jars).
LibraryArtifact firstJar = target.javaIdeInfo.jars.iterator().next();
builder.add(new AarLibrary(firstJar, target.androidAarIdeInfo.aar));
}
return builder.build();
}
use of com.google.idea.blaze.android.sync.model.AarLibrary 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.model.AarLibrary in project intellij by bazelbuild.
the class UnpackedAars method onSync.
void onSync(BlazeContext context, ProjectViewSet projectViewSet, BlazeProjectData projectData, BlazeSyncParams.SyncMode syncMode) {
Collection<BlazeLibrary> libraries = BlazeLibraryCollector.getLibraries(projectViewSet, projectData);
boolean fullRefresh = syncMode == SyncMode.FULL;
boolean removeMissingFiles = syncMode == SyncMode.INCREMENTAL;
if (!enabled || fullRefresh) {
clearCache();
}
if (!enabled) {
return;
}
List<AarLibrary> aarLibraries = libraries.stream().filter(library -> library instanceof AarLibrary).map(library -> (AarLibrary) library).collect(Collectors.toList());
ArtifactLocationDecoder artifactLocationDecoder = projectData.artifactLocationDecoder;
BiMap<File, String> sourceAarFileToCacheKey = HashBiMap.create(aarLibraries.size());
BiMap<File, String> sourceJarFileToCacheKey = HashBiMap.create(aarLibraries.size());
for (AarLibrary library : aarLibraries) {
File aarFile = artifactLocationDecoder.decode(library.aarArtifact);
String cacheKey = cacheKeyForAar(aarFile);
sourceAarFileToCacheKey.put(aarFile, cacheKey);
File jarFile = artifactLocationDecoder.decode(library.libraryArtifact.jarForIntellijLibrary());
// Use the aar key for the jar as well.
sourceJarFileToCacheKey.put(jarFile, cacheKey);
}
this.aarTraits = new AarTraits(cacheDir, sourceAarFileToCacheKey);
this.jarTraits = new JarTraits(cacheDir, sourceJarFileToCacheKey);
refresh(context, removeMissingFiles);
}
Aggregations