use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testPackageManifestCreated.
@Test
public void testPackageManifestCreated() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'simple',", " srcs = ['simple/Simple.java']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
ArtifactLocation packageManifest = targetIdeInfo.getJavaIdeInfo().getPackageManifest();
assertNotNull(packageManifest);
assertEquals(packageManifest.getRelativePath(), "com/google/example/simple.manifest");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testSimplePyTest.
@Test
public void testSimplePyTest() throws Exception {
scratch.file("com/google/example/BUILD", "py_test(", " name = 'simple',", " srcs = ['simple/simple.py'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
assertThat(targetIdeInfos).hasSize(2);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(targetIdeInfo.getKindString()).isEqualTo("py_test");
assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
assertThat(relativePathsForPySourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.py");
assertThat(targetIdeInfo.hasPyIdeInfo()).isTrue();
assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/simple/simple.py");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTestBase method buildIdeInfo.
/**
* Returns a map of (label as string) -> TargetIdeInfo for each rule in the transitive closure of
* the passed target.
*/
protected Map<String, TargetIdeInfo> buildIdeInfo(String target) throws Exception {
buildTarget(target);
AndroidStudioInfoFilesProvider provider = configuredAspect.getProvider(AndroidStudioInfoFilesProvider.class);
Iterable<Artifact> artifacts = provider.getIdeInfoFiles();
Map<String, TargetIdeInfo> ruleIdeInfos = new HashMap<>();
for (Artifact artifact : artifacts) {
Action generatingAction = getGeneratingAction(artifact);
if (generatingAction instanceof BinaryFileWriteAction) {
BinaryFileWriteAction writeAction = (BinaryFileWriteAction) generatingAction;
TargetIdeInfo ruleIdeInfo = TargetIdeInfo.parseFrom(writeAction.getSource().openStream());
ruleIdeInfos.put(ruleIdeInfo.getLabel(), ruleIdeInfo);
} else {
verifyPackageManifestSpawnAction(generatingAction);
}
}
return ruleIdeInfos;
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testJavaLibraryWithGeneratedSourcesHasGenJars.
@Test
public void testJavaLibraryWithGeneratedSourcesHasGenJars() throws Exception {
scratch.file("java/com/google/example/BUILD", "java_library(", " name = 'test',", " srcs = ['Test.java'],", " plugins = [':plugin']", ")", "java_plugin(", " name = 'plugin',", " processor_class = 'com.google.example.Plugin',", " deps = ['plugin_lib'],", ")", "java_library(", " name = 'plugin_lib',", " srcs = ['Plugin.java'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//java/com/google/example:test");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//java/com/google/example:test", targetIdeInfos);
assertThat(transform(targetIdeInfo.getJavaIdeInfo().getGeneratedJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("java/com/google/example", "libtest-gen.jar", null, "libtest-gensrc.jar"));
assertThat(getIdeResolveFiles()).containsExactly("java/com/google/example/libtest.jar", "java/com/google/example/libtest-hjar.jar", "java/com/google/example/libtest-src.jar", "java/com/google/example/libtest-gen.jar", "java/com/google/example/libtest-gensrc.jar");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testSimpleCCLibraryWithCompilerFlags.
@Test
public void testSimpleCCLibraryWithCompilerFlags() throws Exception {
scratch.file("com/google/example/BUILD", "cc_library(", " name = 'simple',", " srcs = ['simple/simple.cc'],", " hdrs = ['simple/simple.h'],", " copts = ['-DGOPT', '-Ifoo/baz/'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
assertThat(targetIdeInfos).hasSize(2);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
assertThat(cTargetIdeInfo.getTargetCoptList()).containsExactly("-DGOPT", "-Ifoo/baz/");
// Make sure our understanding of where this attributes show up in other providers is correct.
Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
CToolchainIdeInfo cToolchainIdeInfo = toolchainInfo.getCToolchainIdeInfo();
ProtocolStringList baseCompilerOptionList = cToolchainIdeInfo.getBaseCompilerOptionList();
assertThat(baseCompilerOptionList).doesNotContain("-DGOPT");
assertThat(baseCompilerOptionList).doesNotContain("-Ifoo/baz/");
ProtocolStringList cOptionList = cToolchainIdeInfo.getCOptionList();
assertThat(cOptionList).doesNotContain("-DGOPT");
assertThat(cOptionList).doesNotContain("-Ifoo/baz/");
ProtocolStringList cppOptionList = cToolchainIdeInfo.getCppOptionList();
assertThat(cppOptionList).doesNotContain("-DGOPT");
assertThat(cppOptionList).doesNotContain("-Ifoo/baz/");
}
Aggregations