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