Search in sources :

Example 46 with TargetIdeInfo

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

the class AndroidStudioInfoAspectTest method testSimplePyBinary.

@Test
public void testSimplePyBinary() throws Exception {
    scratch.file("com/google/example/BUILD", "py_binary(", "    name = 'simple',", "    srcs = ['simple/simple.py'],", ")");
    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("py_binary");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
    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)

Example 47 with TargetIdeInfo

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

the class AndroidStudioInfoAspectTest method testAndroidBinaryIsSerialized.

@Test
public void testAndroidBinaryIsSerialized() throws Exception {
    TargetIdeInfo.Builder builder = TargetIdeInfo.newBuilder();
    builder.setKindString("android_binary");
    ByteString byteString = builder.build().toByteString();
    TargetIdeInfo result = TargetIdeInfo.parseFrom(byteString);
    assertThat(result.getKindString()).isEqualTo("android_binary");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 48 with TargetIdeInfo

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

the class AndroidStudioInfoAspectTest method testNoPackageManifestForExports.

@Test
public void testNoPackageManifestForExports() throws Exception {
    scratch.file("com/google/example/BUILD", "java_library(", "   name = 'foobar',", "   srcs = ['FooBar.java'],", ")", "java_import(", "   name = 'imp',", "   jars = ['a.jar', 'b.jar'],", "   deps = [':foobar'],", "   exports = [':foobar'],", ")", "java_library(", "   name = 'lib',", "   srcs = ['Lib.java'],", "   deps = [':imp'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
    TargetIdeInfo libInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
    TargetIdeInfo impInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:imp", targetIdeInfos);
    assertThat(!impInfo.getJavaIdeInfo().hasPackageManifest()).isTrue();
    assertThat(libInfo.getJavaIdeInfo().hasPackageManifest()).isTrue();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 49 with TargetIdeInfo

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

the class AndroidStudioInfoAspectTest method testRuntimeDepsAddedToProto.

@Test
public void testRuntimeDepsAddedToProto() throws Exception {
    scratch.file("com/google/example/BUILD", "java_library(", "   name = 'foobar',", "   srcs = ['FooBar.java'],", ")", "java_library(", "   name = 'foobar2',", "   srcs = ['FooBar2.java'],", ")", "java_library(", "   name = 'lib',", "   srcs = ['Lib.java'],", "   deps = [':lib2'],", "   runtime_deps = [':foobar'],", ")", "java_library(", "   name = 'lib2',", "   srcs = ['Lib2.java'],", "   runtime_deps = [':foobar2'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
    // Fails if aspect was not propagated
    TargetIdeInfo lib = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
    TargetIdeInfo lib2 = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib2", targetIdeInfos);
    assertThat(lib.getRuntimeDepsList()).containsExactly("//com/google/example:foobar");
    assertThat(lib2.getRuntimeDepsList()).containsExactly("//com/google/example:foobar2");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 50 with TargetIdeInfo

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

the class AndroidStudioInfoAspectTest method testJavaPlugin.

@Test
public void testJavaPlugin() throws Exception {
    scratch.file("java/com/google/example/BUILD", "java_plugin(", "  name = 'plugin',", "  srcs = ['Plugin.java'],", "  processor_class = 'com.google.example.Plugin',", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//java/com/google/example:plugin");
    TargetIdeInfo plugin = getTargetIdeInfoAndVerifyLabel("//java/com/google/example:plugin", targetIdeInfos);
    assertThat(plugin.getKindString()).isEqualTo("java_plugin");
    assertThat(transform(plugin.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("java/com/google/example", "libplugin.jar", "libplugin-hjar.jar", "libplugin-src.jar"));
}
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