use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testSimpleCCBinary.
@Test
public void testSimpleCCBinary() throws Exception {
scratch.file("com/google/example/BUILD", "cc_binary(", " name = 'simple',", " srcs = ['simple/simple.cc'],", ")");
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("cc_binary");
assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
assertThat(relativePathsForCSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.cc");
assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
assertThat(getIdeResolveFiles()).isEmpty();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testMacroDoesntAffectRuleClass.
@Test
public void testMacroDoesntAffectRuleClass() throws Exception {
scratch.file("java/com/google/example/build_defs.bzl", "def my_macro(name):", " native.android_binary(", " name = name,", " srcs = ['simple/Simple.java'],", " manifest = 'AndroidManifest.xml',", ")");
scratch.file("java/com/google/example/BUILD", "load('//java/com/google/example:build_defs.bzl', 'my_macro')", "my_macro(", " name = 'simple',", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//java/com/google/example:simple");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//java/com/google/example:simple", targetIdeInfos);
assertThat(targetIdeInfo.getKindString()).isEqualTo("android_binary");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testAndroidBinary.
@Test
public void testAndroidBinary() 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_binary(", " name = 'b',", " 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:b");
TargetIdeInfo target = getTargetIdeInfoAndVerifyLabel("//com/google/example:b", targetIdeInfos);
assertThat(target.getKindString()).isEqualTo("android_binary");
assertThat(relativePathsForJavaSourcesOf(target)).containsExactly("com/google/example/Main.java");
assertThat(transform(target.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("com/google/example", "libb.jar", "libb-hjar.jar", "libb-src.jar"), jarString("com/google/example", "b_resources.jar", null, "b_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(target.getAndroidIdeInfo().getApk().getRelativePath()).isEqualTo("com/google/example/b.apk");
assertThat(target.getDependenciesList()).contains("//com/google/example:l1");
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/libb.jar", "com/google/example/libb-hjar.jar", "com/google/example/libb-src.jar", "com/google/example/b_resources.jar", "com/google/example/b_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/libb.jdeps");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testJavaBinary.
@Test
public void testJavaBinary() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'foobar',", " srcs = ['FooBar.java'],", ")", "java_binary(", " name = 'foobar-exe',", " main_class = 'MyMainClass',", " srcs = ['FooBarMain.java'],", " deps = [':foobar'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:foobar-exe");
TargetIdeInfo binaryInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:foobar-exe", targetIdeInfos);
assertThat(binaryInfo.getKindString()).isEqualTo("java_binary");
assertThat(relativePathsForJavaSourcesOf(binaryInfo)).containsExactly("com/google/example/FooBarMain.java");
assertThat(binaryInfo.getDependenciesList()).contains("//com/google/example:foobar");
assertThat(transform(binaryInfo.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("com/google/example", "foobar-exe.jar", null, "foobar-exe-src.jar"));
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/libfoobar.jar", "com/google/example/libfoobar-hjar.jar", "com/google/example/libfoobar-src.jar", "com/google/example/foobar-exe.jar", "com/google/example/foobar-exe-src.jar");
assertThat(binaryInfo.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo("com/google/example/foobar-exe.jdeps");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testJavaLibraryWithDependencies.
@Test
public void testJavaLibraryWithDependencies() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'simple',", " srcs = ['simple/Simple.java']", ")", "java_library(", " name = 'complex',", " srcs = ['complex/Complex.java'],", " deps = [':simple']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:complex");
getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
TargetIdeInfo complexTarget = getTargetIdeInfoAndVerifyLabel("//com/google/example:complex", targetIdeInfos);
assertThat(relativePathsForJavaSourcesOf(complexTarget)).containsExactly("com/google/example/complex/Complex.java");
assertThat(complexTarget.getDependenciesList()).contains("//com/google/example:simple");
}
Aggregations