Search in sources :

Example 11 with TargetIdeInfo

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();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 12 with TargetIdeInfo

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");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 13 with TargetIdeInfo

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");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 14 with TargetIdeInfo

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");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 15 with TargetIdeInfo

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");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)58 ByteString (com.google.protobuf.ByteString)55 Test (org.junit.Test)55 ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)10 ProtocolStringList (com.google.protobuf.ProtocolStringList)7 CToolchainIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo)5 JavaIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo)3 Artifact (com.google.devtools.build.lib.actions.Artifact)2 LibraryArtifact (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)2 Action (com.google.devtools.build.lib.actions.Action)1 BinaryFileWriteAction (com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction)1 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)1 AndroidIdeInfoProvider (com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider)1 CcToolchainProvider (com.google.devtools.build.lib.rules.cpp.CcToolchainProvider)1 CppCompilationContext (com.google.devtools.build.lib.rules.cpp.CppCompilationContext)1 CppConfiguration (com.google.devtools.build.lib.rules.cpp.CppConfiguration)1 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)1 JavaToolchainProvider (com.google.devtools.build.lib.rules.java.JavaToolchainProvider)1 TestInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TestInfo)1