use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testTags.
@Test
public void testTags() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'lib',", " srcs = ['Test.java'],", " tags = ['d', 'b', 'c', 'a'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
assertThat(targetIdeInfo.getTagsList()).containsExactly("a", "b", "c", "d");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testCcToolchainInfoIsOnlyPresentForToolchainRules.
@Test
public void testCcToolchainInfoIsOnlyPresentForToolchainRules() throws Exception {
scratch.file("com/google/example/BUILD", "cc_library(", " name = 'simple',", " srcs = ['simple/simple.cc'],", " hdrs = ['simple/simple.h'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
assertThat(targetIdeInfos).hasSize(2);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(targetIdeInfo.hasCToolchainIdeInfo()).isFalse();
assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testAndroidLibraryWithAidlHasIdlJars.
@Test
public void testAndroidLibraryWithAidlHasIdlJars() throws Exception {
scratch.file("java/com/google/example/BUILD", "android_library(", " name = 'has_idl',", " idl_srcs = ['a.aidl'],", ")");
String idlTarget = "//java/com/google/example:has_idl";
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo(idlTarget);
TargetIdeInfo idlTargetIdeInfo = getTargetIdeInfoAndVerifyLabel(idlTarget, targetIdeInfos);
assertThat(idlTargetIdeInfo.getAndroidIdeInfo().getHasIdlSources()).isTrue();
assertThat(LIBRARY_ARTIFACT_TO_STRING.apply(idlTargetIdeInfo.getAndroidIdeInfo().getIdlJar())).isEqualTo(jarString("java/com/google/example", "libhas_idl-idl.jar", null, "libhas_idl-idl.srcjar"));
assertThat(relativePathsForJavaSourcesOf(idlTargetIdeInfo)).isEmpty();
assertThat(getIdeResolveFiles()).containsExactly("java/com/google/example/libhas_idl.jar", "java/com/google/example/libhas_idl-hjar.jar", "java/com/google/example/libhas_idl-src.jar", "java/com/google/example/libhas_idl-idl.jar", "java/com/google/example/libhas_idl-idl.srcjar");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testJavaToolchain.
@Test
public void testJavaToolchain() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'a',", " srcs = ['A.java'],", " deps = [':b'],", ")", "java_library(", " name = 'b',", " srcs = ['B.java'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:a");
List<TargetIdeInfo> javaToolChainInfos = findJavaToolchain(targetIdeInfos);
// Ensure we don't get one instance per java_library
assertThat(javaToolChainInfos).hasSize(1);
TargetIdeInfo toolChainInfo = Iterables.getOnlyElement(javaToolChainInfos);
assertThat(toolChainInfo.getJavaToolchainIdeInfo().getSourceVersion()).isNotEmpty();
assertThat(toolChainInfo.getJavaToolchainIdeInfo().getTargetVersion()).isNotEmpty();
TargetIdeInfo a = targetIdeInfos.get("//com/google/example:a");
assertThat(a.getDependenciesList()).containsAllOf("//com/google/example:b", toolChainInfo.getLabel());
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testAndroidLibrary.
@Test
public void testAndroidLibrary() throws Exception {
scratch.file("com/google/example/BUILD", "android_library(", " name = 'l1',", " manifest = 'AndroidManifest.xml',", " custom_package = 'com.google.example',", " resource_files = ['r1/values/a.xml'],", ")", "android_library(", " name = 'l',", " srcs = ['Main.java'],", " deps = [':l1'],", " manifest = 'AndroidManifest.xml',", " custom_package = 'com.google.example',", " resource_files = ['res/drawable/a.png', 'res/drawable/b.png'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:l");
TargetIdeInfo target = getTargetIdeInfoAndVerifyLabel("//com/google/example:l", targetIdeInfos);
assertThat(target.getKindString()).isEqualTo("android_library");
assertThat(relativePathsForJavaSourcesOf(target)).containsExactly("com/google/example/Main.java");
assertThat(transform(target.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("com/google/example", "libl.jar", "libl-hjar.jar", "libl-src.jar"), jarString("com/google/example", "l_resources.jar", null, "l_resources-src.jar"));
assertThat(transform(target.getAndroidIdeInfo().getResourcesList(), ARTIFACT_TO_RELATIVE_PATH)).containsExactly("com/google/example/res");
assertThat(target.getAndroidIdeInfo().getManifest().getRelativePath()).isEqualTo("com/google/example/AndroidManifest.xml");
assertThat(target.getAndroidIdeInfo().getJavaPackage()).isEqualTo("com.google.example");
assertThat(LIBRARY_ARTIFACT_TO_STRING.apply(target.getAndroidIdeInfo().getResourceJar())).isEqualTo(jarString("com/google/example", "l_resources.jar", null, "l_resources-src.jar"));
assertThat(target.getDependenciesList()).contains("//com/google/example:l1");
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/libl.jar", "com/google/example/libl-hjar.jar", "com/google/example/libl-src.jar", "com/google/example/l_resources.jar", "com/google/example/l_resources-src.jar", "com/google/example/libl1.jar", "com/google/example/libl1-src.jar", "com/google/example/l1_resources.jar", "com/google/example/l1_resources-src.jar");
assertThat(target.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo("com/google/example/libl.jdeps");
}
Aggregations