use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation 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.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testExternalRootCorrectlyIdentified.
@Test
public void testExternalRootCorrectlyIdentified() throws Exception {
ArtifactLocation location = AndroidStudioInfoAspect.makeArtifactLocation(Root.asSourceRoot(outputBase, false), new PathFragment("external/foo/bar.jar"), true);
assertThat(location.getIsExternal()).isTrue();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation 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.ArtifactLocation 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");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation 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");
}
Aggregations