use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class BlazeApkBuildStepNormalBuild method getTargetToBuild.
/**
* In case we're dealing with an {@link Kind#ANDROID_INSTRUMENTATION_TEST}, build the underlying
* {@link Kind#ANDROID_BINARY} instead.
*/
private Label getTargetToBuild() {
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData == null) {
return label;
}
TargetMap targetMap = projectData.targetMap;
TargetIdeInfo target = targetMap.get(TargetKey.forPlainTarget(label));
if (target == null || target.kind != Kind.ANDROID_INSTRUMENTATION_TEST) {
return label;
}
for (Dependency dependency : target.dependencies) {
TargetIdeInfo dependencyInfo = targetMap.get(dependency.targetKey);
// Should exist via test_app attribute, and be unique.
if (dependencyInfo != null && dependencyInfo.kind == Kind.ANDROID_BINARY) {
return dependency.targetKey.label;
}
}
return label;
}
use of com.google.idea.blaze.base.model.BlazeProjectData 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);
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class ProjectViewManagerImpl method computeWorkspacePathResolver.
@Nullable
private static WorkspacePathResolver computeWorkspacePathResolver(Project project, BlazeContext context) {
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectData != null) {
return projectData.workspacePathResolver;
}
// otherwise try to compute the workspace path resolver from scratch
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
BlazeVcsHandler vcsHandler = BlazeVcsHandler.vcsHandlerForProject(project);
if (vcsHandler == null) {
return null;
}
BlazeVcsHandler.BlazeVcsSyncHandler vcsSyncHandler = vcsHandler.createSyncHandler(project, workspaceRoot);
if (vcsSyncHandler == null) {
return new WorkspacePathResolverImpl(workspaceRoot);
}
boolean ok = vcsSyncHandler.update(context, BlazeExecutor.getInstance().getExecutor());
return ok ? vcsSyncHandler.getWorkspacePathResolver() : null;
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class TestTargetSourcesHeuristicTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
super.initTest(applicationServices, projectServices);
BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
ExtensionPointImpl<TestTargetHeuristic> ep = registerExtensionPoint(TestTargetHeuristic.EP_NAME, TestTargetHeuristic.class);
ep.registerExtension(new TestTargetSourcesHeuristic());
}
use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.
the class ScalaSyncTest method testSimpleSync.
@Test
public void testSimpleSync() throws Exception {
setProjectView("directories:", " src/main/scala/com/google", "targets:", " //src/main/scala/com/google:lib", "additional_languages:", " scala");
workspace.createFile(new WorkspacePath("src/main/scala/com/google/Source.scala"), "package com.google;", "public class Source {}");
workspace.createFile(new WorkspacePath("src/main/scala/com/google/Other.scala"), "package com.google;", "public class Other {}");
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/scala/com/google/BUILD")).setLabel("//src/main/scala/com/google:lib").setKind("scala_library").addSource(sourceRoot("src/main/scala/com/google/Source.scala")).addSource(sourceRoot("src/main/scala/com/google/Other.scala"))).build();
setTargetMap(targetMap);
runBlazeSync(new BlazeSyncParams.Builder("Sync", SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
errorCollector.assertNoIssues();
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
assertThat(blazeProjectData).isNotNull();
assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
assertThat(blazeProjectData.workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.SCALA, LanguageClass.JAVA)));
}
Aggregations