use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class FastBuildCompilerFactoryImplTest method configureTestForTargetMap.
private void configureTestForTargetMap(Map<TargetKey, TargetIdeInfo> targetMap) {
BlazeProjectData projectData = new BlazeProjectData(0, new TargetMap(ImmutableMap.copyOf(targetMap)), null, null, null, artifact -> new File(artifact.relativePath), null, null, null);
BlazeProjectDataManager projectDataManager = new MockBlazeProjectDataManager(projectData);
compilerFactory = new FastBuildCompilerFactoryImpl(projectDataManager);
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class PluginDevSyncTest method testRunConfigurationCreatedDuringSync.
@Test
public void testRunConfigurationCreatedDuringSync() throws Exception {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", " //java/com/google:plugin", "workspace_type: intellij_plugin");
workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName1.java"), "package com.google;", "public class ClassWithUniqueName1 {}");
workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName2.java"), "package com.google;", "public class ClassWithUniqueName2 {}");
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("java_library").addSource(sourceRoot("java/com/google/ClassWithUniqueName1.java")).addSource(sourceRoot("java/com/google/ClassWithUniqueName2.java"))).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:plugin").setKind("intellij_plugin_debug_target")).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.getWorkspaceType()).isEqualTo(WorkspaceType.INTELLIJ_PLUGIN);
List<RunConfiguration> runConfigs = RunManager.getInstance(getProject()).getAllConfigurationsList();
assertThat(runConfigs).hasSize(1);
assertThat(runConfigs.get(0)).isInstanceOf(BlazeIntellijPluginConfiguration.class);
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class KotlinSyncTest method testKotlinClassesPresentInClassPath.
@Test
public void testKotlinClassesPresentInClassPath() {
setProjectView("directories:", " src/main/kotlin/com/google", "targets:", " //src/main/kotlin/com/google:lib", "additional_languages:", " kotlin");
workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/ClassWithUniqueName1.kt"), "package com.google;", "public class ClassWithUniqueName1 {}");
workspace.createFile(new WorkspacePath("src/main/kotlin/com/google/ClassWithUniqueName2.kt"), "package com.google;", "public class ClassWithUniqueName2 {}");
workspace.createDirectory(new WorkspacePath("external/com_github_jetbrains_kotlin"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("src/main/kotlin/com/google/BUILD")).setLabel("//src/main/kotlin/com/google:lib").setKind("kt_jvm_library").addSource(sourceRoot("src/main/kotlin/com/google/ClassWithUniqueName1.scala")).addSource(sourceRoot("src/main/kotlin/com/google/ClassWithUniqueName2.scala")).setJavaInfo(JavaIdeInfo.builder())).build();
setTargetMap(targetMap);
BlazeSyncParams syncParams = new BlazeSyncParams.Builder("Full Sync", BlazeSyncParams.SyncMode.FULL).addProjectViewTargets(true).build();
runBlazeSync(syncParams);
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.JAVA, LanguageClass.KOTLIN)));
BlazeJavaSyncData javaSyncData = blazeProjectData.syncState.get(BlazeJavaSyncData.class);
assertThat(javaSyncData).isNotNull();
List<BlazeContentEntry> contentEntries = javaSyncData.importResult.contentEntries;
assertThat(contentEntries).hasSize(1);
BlazeContentEntry contentEntry = contentEntries.get(0);
assertThat(contentEntry.contentRoot.getPath()).isEqualTo(this.workspaceRoot.fileForPath(new WorkspacePath("src/main/kotlin/com/google")).getPath());
assertThat(contentEntry.sources).hasSize(1);
BlazeSourceDirectory sourceDir = contentEntry.sources.get(0);
assertThat(sourceDir.getPackagePrefix()).isEqualTo("com.google");
assertThat(sourceDir.getDirectory().getPath()).isEqualTo(this.workspaceRoot.fileForPath(new WorkspacePath("src/main/kotlin/com/google")).getPath());
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class AndroidSyncTest method testSimpleSync.
@Test
public void testSimpleSync() throws Exception {
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:lib", "android_sdk_platform: android-25");
workspace.createFile(new WorkspacePath("java/com/google/Source.java"), "package com.google;", "public class Source {}");
workspace.createFile(new WorkspacePath("java/com/google/Other.java"), "package com.google;", "public class Other {}");
VirtualFile javaRoot = workspace.createDirectory(new WorkspacePath("java/com/google"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("android_library").setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(sourceRoot("java/com/google/AndroidManifest.xml")).addResource(sourceRoot("java/com/google/res/values/strings.xml")).setResourceJavaPackage("com.google").setGenerateResourceClass(true)).addSource(sourceRoot("java/com/google/Source.java")).addSource(sourceRoot("java/com/google/Other.java"))).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.getWorkspaceType()).isEqualTo(WorkspaceType.ANDROID);
ImmutableList<ContentEntry> contentEntries = getWorkspaceContentEntries();
assertThat(contentEntries).hasSize(1);
assertThat(findContentEntry(javaRoot)).isNotNull();
assertThat(findContentEntry(javaRoot).getSourceFolders()).hasLength(1);
// Check that the workspace is set to android
Module workspaceModule = ModuleFinder.getInstance(getProject()).findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME);
assertThat(workspaceModule).isNotNull();
assertThat(AndroidFacet.getInstance(workspaceModule)).isNotNull();
// Check that a resource module was created
Module resourceModule = ModuleFinder.getInstance(getProject()).findModuleByName("java.com.google.lib");
assertThat(resourceModule).isNotNull();
assertThat(AndroidFacet.getInstance(resourceModule)).isNotNull();
}
use of com.google.idea.blaze.base.ideinfo.TargetMap in project intellij by bazelbuild.
the class BlazeBuildSystemServiceTest method createMockBlazeProjectData.
private BlazeProjectData createMockBlazeProjectData() {
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(Label.create("//foo:bar")).setBuildFile(ArtifactLocation.builder().setRelativePath("foo/BUILD").build()).build()).build();
ArtifactLocationDecoder decoder = (location) -> new File("/", location.getRelativePath());
return MockBlazeProjectDataBuilder.builder(workspaceRoot).setTargetMap(targetMap).setArtifactLocationDecoder(decoder).build();
}
Aggregations