use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testPackageManifestNotCreatedForOnlyGeneratedSources.
@Test
public void testPackageManifestNotCreatedForOnlyGeneratedSources() throws Exception {
scratch.file("com/google/example/BUILD", "genrule(", " name = 'gen_sources',", " outs = ['Gen.java'],", " cmd = '',", ")", "java_library(", " name = 'simple',", " srcs = [':gen_sources']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
assertThat(targetIdeInfo.getJavaIdeInfo().hasPackageManifest()).isFalse();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testTransitiveCCLibraryWithIncludes.
@Test
public void testTransitiveCCLibraryWithIncludes() throws Exception {
scratch.file("com/google/example/BUILD", "cc_library(", " name = 'lib2',", " srcs = ['lib2/lib2.cc'],", " hdrs = ['lib2/lib2.h'],", " includes = ['baz/lib'],", ")", "cc_library(", " name = 'lib1',", " srcs = ['lib1/lib1.cc'],", " hdrs = ['lib1/lib1.h'],", " includes = ['foo/bar'],", " 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 cTargetIdeInfo = lib1.getCIdeInfo();
assertThat(cTargetIdeInfo.getTargetIncludeList()).containsExactly("foo/bar");
// Make sure our understanding of where this attributes show up in other providers is correct.
Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
CToolchainIdeInfo cToolchainIdeInfo = toolchainInfo.getCToolchainIdeInfo();
ProtocolStringList builtInIncludeDirectoryList = cToolchainIdeInfo.getBuiltInIncludeDirectoryList();
assertThat(builtInIncludeDirectoryList).doesNotContain("foo/bar");
assertThat(builtInIncludeDirectoryList).doesNotContain("baz/lib");
assertThat(builtInIncludeDirectoryList).doesNotContain("com/google/example/foo/bar");
assertThat(builtInIncludeDirectoryList).doesNotContain("com/google/example/baz/lib");
ProtocolStringList transIncludeDirList = cTargetIdeInfo.getTransitiveIncludeDirectoryList();
assertThat(transIncludeDirList).doesNotContain("foo/bar");
assertThat(transIncludeDirList).doesNotContain("baz/lib");
assertThat(transIncludeDirList).doesNotContain("com/google/example/foo/bar");
assertThat(transIncludeDirList).doesNotContain("com/google/example/baz/lib");
ProtocolStringList transQuoteIncludeDirList = cTargetIdeInfo.getTransitiveQuoteIncludeDirectoryList();
assertThat(transQuoteIncludeDirList).doesNotContain("foo/bar");
assertThat(transQuoteIncludeDirList).doesNotContain("baz/lib");
assertThat(transQuoteIncludeDirList).doesNotContain("com/google/example/foo/bar");
assertThat(transQuoteIncludeDirList).doesNotContain("com/google/example/baz/lib");
ProtocolStringList transSysIncludeDirList = cTargetIdeInfo.getTransitiveSystemIncludeDirectoryList();
assertThat(transSysIncludeDirList).doesNotContain("foo/bar");
assertThat(transSysIncludeDirList).doesNotContain("baz/lib");
assertThat(transSysIncludeDirList).contains("com/google/example/foo/bar");
assertThat(transSysIncludeDirList).contains("com/google/example/baz/lib");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testFilteredGenJar.
@Test
public void testFilteredGenJar() throws Exception {
scratch.file("com/google/example/BUILD", "genrule(", " name = 'gen_sources',", " outs = ['Gen.java'],", " cmd = '',", ")", "genrule(", " name = 'gen_srcjar',", " outs = ['gen.srcjar'],", " cmd = '',", ")", "java_library(", " name = 'lib',", " srcs = [':gen_sources', ':gen_srcjar', 'Test.java']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib", targetIdeInfos);
assertThat(targetIdeInfo.getJavaIdeInfo().hasFilteredGenJar()).isTrue();
assertThat(targetIdeInfo.getJavaIdeInfo().getFilteredGenJar().getJar().getRelativePath()).isEqualTo("com/google/example/lib-filtered-gen.jar");
assertThat(targetIdeInfo.getJavaIdeInfo().getFilteredGenJar().getSourceJar().getRelativePath()).isEqualTo("com/google/example/lib-filtered-gen-src.jar");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testExternalTarget.
@Test
public void testExternalTarget() throws Exception {
scratch.file("/r/BUILD", "java_import(", " name = 'junit',", " jars = ['junit.jar'],", ")");
scratch.file("/r/junit.jar");
// AnalysisMock adds required toolchains, etc. to WORKSPACE, so retain the previous contents.
String oldContents = scratch.readFile("WORKSPACE");
scratch.overwriteFile("WORKSPACE", oldContents + "\nlocal_repository(name='r', path='/r')");
invalidatePackages();
scratch.file("com/google/example/BUILD", "java_library(", " name = 'junit',", " exports = ['@r//:junit'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:junit");
assertThat(getTargetIdeInfoAndVerifyLabel("//com/google/example:junit", targetIdeInfos).getBuildFileArtifactLocation().getIsExternal()).isFalse();
TargetIdeInfo targetInfo = getTargetIdeInfoAndVerifyLabel("@r//:junit", targetIdeInfos);
assertThat(targetInfo.getBuildFileArtifactLocation().getIsExternal()).isTrue();
assertThat(targetInfo.getBuildFileArtifactLocation().getRelativePath()).startsWith("external");
JavaIdeInfo javaInfo = targetInfo.getJavaIdeInfo();
assertThat(javaInfo.getJarsList()).hasSize(1);
ArtifactLocation jar = javaInfo.getJars(0).getJar();
assertThat(jar.getIsSource()).isTrue();
assertThat(jar.getIsExternal()).isTrue();
assertThat(jar.getRelativePath()).isEqualTo("external/r/junit.jar");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testFilteredGenJarNotCreatedForOnlyGenRule.
@Test
public void testFilteredGenJarNotCreatedForOnlyGenRule() throws Exception {
scratch.file("com/google/example/BUILD", "genrule(", " name = 'gen_sources',", " outs = ['Gen.java'],", " cmd = '',", ")", "java_library(", " name = 'simple',", " srcs = [':gen_sources']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
assertThat(targetIdeInfo.getJavaIdeInfo().hasFilteredGenJar()).isFalse();
}
Aggregations