Search in sources :

Example 41 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testJavaLibraryWithoutGeneratedSourcesHasNoGenJars.

@Test
public void testJavaLibraryWithoutGeneratedSourcesHasNoGenJars() throws Exception {
    scratch.file("java/com/google/example/BUILD", "java_library(", "  name = 'no_plugin',", "  srcs = ['Test.java'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//java/com/google/example:no_plugin");
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//java/com/google/example:no_plugin", targetIdeInfos);
    assertThat(targetIdeInfo.getJavaIdeInfo().getGeneratedJarsList()).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 42 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleJavaLibrary.

@Test
public void testSimpleJavaLibrary() 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 location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(location.getIsSource()).isTrue();
    assertThat(location.getIsExternal()).isFalse();
    assertThat(targetIdeInfo.getKindString()).isEqualTo("java_library");
    assertThat(relativePathsForJavaSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/Simple.java");
    assertThat(transform(targetIdeInfo.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("com/google/example", "libsimple.jar", "libsimple-hjar.jar", "libsimple-src.jar"));
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/libsimple.jar", "com/google/example/libsimple-hjar.jar", "com/google/example/libsimple-src.jar");
    assertThat(targetIdeInfo.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo("com/google/example/libsimple.jdeps");
}
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 43 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testJavaImport.

@Test
public void testJavaImport() throws Exception {
    scratch.file("com/google/example/BUILD", "java_import(", "   name = 'imp',", "   jars = ['a.jar', 'b.jar'],", "   srcjar = 'impsrc.jar',", ")", "java_library(", "   name = 'lib',", "   srcs = ['Lib.java'],", "   deps = [':imp'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
    final TargetIdeInfo libInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
    TargetIdeInfo impInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:imp", targetIdeInfos);
    assertThat(impInfo.getKindString()).isEqualTo("java_import");
    assertThat(libInfo.getDependenciesList()).contains("//com/google/example:imp");
    JavaIdeInfo javaIdeInfo = impInfo.getJavaIdeInfo();
    assertThat(javaIdeInfo).isNotNull();
    assertThat(transform(javaIdeInfo.getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("com/google/example", "a.jar", "_ijar/imp/com/google/example/a-ijar.jar", "impsrc.jar"), jarString("com/google/example", "b.jar", "_ijar/imp/com/google/example/b-ijar.jar", "impsrc.jar")).inOrder();
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/_ijar/imp/com/google/example/a-ijar.jar", "com/google/example/_ijar/imp/com/google/example/b-ijar.jar", "com/google/example/liblib.jar", "com/google/example/liblib-hjar.jar", "com/google/example/liblib-src.jar");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) JavaIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo) Test(org.junit.Test)

Example 44 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testTransitiveCCLibraryWithDefines.

@Test
public void testTransitiveCCLibraryWithDefines() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'lib2',", "    srcs = ['lib2/lib2.cc'],", "    hdrs = ['lib2/lib2.h'],", "    defines = ['COMPLEX_IMPL'],", ")", "cc_library(", "    name = 'lib1',", "    srcs = ['lib1/lib1.cc'],", "    hdrs = ['lib1/lib1.h'],", "    defines = ['VERSION2'],", "    deps = [':lib2'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib1");
    assertThat(targetIdeInfos).hasSize(3);
    TargetIdeInfo lib1 = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib1", targetIdeInfos);
    assertThat(lib1.hasCIdeInfo()).isTrue();
    CIdeInfo cIdeInfo = lib1.getCIdeInfo();
    assertThat(cIdeInfo.getTargetDefineList()).containsExactly("VERSION2");
    // Make sure our understanding of where this attributes show up in other providers is correct.
    ProtocolStringList transDefineList = cIdeInfo.getTransitiveDefineList();
    assertThat(transDefineList).contains("VERSION2");
    assertThat(transDefineList).contains("COMPLEX_IMPL");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Example 45 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimplePyLibrary.

@Test
public void testSimplePyLibrary() throws Exception {
    scratch.file("com/google/example/BUILD", "py_library(", "    name = 'simple',", "    srcs = ['simple/simple.py'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(1);
    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_library");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(0);
    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");
}
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)

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