Search in sources :

Example 26 with TargetIdeInfo

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

Example 27 with TargetIdeInfo

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

Example 28 with TargetIdeInfo

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

Example 29 with TargetIdeInfo

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

Example 30 with TargetIdeInfo

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");
}
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