Search in sources :

Example 11 with ArtifactLocation

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");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) ByteString(com.google.protobuf.ByteString) JavaIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo) Test(org.junit.Test)

Example 12 with ArtifactLocation

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();
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) Test(org.junit.Test)

Example 13 with ArtifactLocation

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");
}
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 14 with ArtifactLocation

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");
}
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 15 with ArtifactLocation

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

ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)15 Test (org.junit.Test)14 TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)12 ByteString (com.google.protobuf.ByteString)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)3 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 Artifact (com.google.devtools.build.lib.actions.Artifact)1 SourceDirectory (com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider.SourceDirectory)1 OutputJar (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.OutputJar)1 AndroidIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.AndroidIdeInfo)1 JavaIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo)1 LibraryArtifact (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)1 ProtocolStringList (com.google.protobuf.ProtocolStringList)1