Search in sources :

Example 1 with ArtifactLocation

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

the class AndroidStudioInfoAspect method makeAndroidIdeInfo.

private static AndroidIdeInfo makeAndroidIdeInfo(AndroidIdeInfoProvider androidIdeInfoProvider, DependenciesResult dependenciesResult, NestedSetBuilder<Artifact> ideResolveArtifacts) {
    AndroidIdeInfo.Builder builder = AndroidIdeInfo.newBuilder();
    if (androidIdeInfoProvider.getSignedApk() != null) {
        builder.setApk(makeArtifactLocation(androidIdeInfoProvider.getSignedApk()));
    }
    Artifact manifest = androidIdeInfoProvider.getManifest();
    if (manifest != null) {
        builder.setManifest(makeArtifactLocation(manifest));
        addResolveArtifact(ideResolveArtifacts, manifest);
    }
    for (Artifact artifact : androidIdeInfoProvider.getApksUnderTest()) {
        builder.addDependencyApk(makeArtifactLocation(artifact));
    }
    for (SourceDirectory resourceDir : androidIdeInfoProvider.getResourceDirs()) {
        ArtifactLocation artifactLocation = makeArtifactLocation(resourceDir);
        builder.addResources(artifactLocation);
    }
    if (androidIdeInfoProvider.getJavaPackage() != null) {
        builder.setJavaPackage(androidIdeInfoProvider.getJavaPackage());
    }
    String idlImportRoot = androidIdeInfoProvider.getIdlImportRoot();
    if (idlImportRoot != null) {
        builder.setIdlImportRoot(idlImportRoot);
    }
    boolean hasIdlSources = !androidIdeInfoProvider.getIdlSrcs().isEmpty();
    builder.setHasIdlSources(hasIdlSources);
    if (hasIdlSources) {
        LibraryArtifact idlLibraryArtifact = makeLibraryArtifact(ideResolveArtifacts, androidIdeInfoProvider.getIdlClassJar(), null, androidIdeInfoProvider.getIdlSourceJar());
        if (idlLibraryArtifact != null) {
            builder.setIdlJar(idlLibraryArtifact);
        }
    }
    builder.setGenerateResourceClass(androidIdeInfoProvider.definesAndroidResources());
    if (dependenciesResult.resources != null) {
        builder.setLegacyResources(dependenciesResult.resources.toString());
    }
    OutputJar resourceJar = androidIdeInfoProvider.getResourceJar();
    if (resourceJar != null) {
        LibraryArtifact resourceLibraryArtifact = makeLibraryArtifact(ideResolveArtifacts, resourceJar.getClassJar(), resourceJar.getIJar(), resourceJar.getSrcJar());
        if (resourceLibraryArtifact != null) {
            builder.setResourceJar(resourceLibraryArtifact);
        }
    }
    return builder.build();
}
Also used : OutputJar(com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.OutputJar) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) SourceDirectory(com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider.SourceDirectory) AndroidIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.AndroidIdeInfo) LibraryArtifact(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact) Artifact(com.google.devtools.build.lib.actions.Artifact) LibraryArtifact(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)

Example 2 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testSimpleCCTest.

@Test
public void testSimpleCCTest() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_test(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", ")");
    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("cc_test");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
    assertThat(relativePathsForCSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.cc");
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
    assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
    assertThat(getIdeResolveFiles()).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testPyTestWithDeps.

@Test
public void testPyTestWithDeps() throws Exception {
    scratch.file("com/google/example/BUILD", "py_library(", "    name = 'lib',", "    srcs = ['lib.py'],", ")", "py_test(", "    name = 'test',", "    srcs = ['test.py'],", "    deps = [':lib'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:test");
    assertThat(targetIdeInfos).hasSize(3);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:test", targetIdeInfos);
    ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(targetIdeInfo.getKindString()).isEqualTo("py_test");
    assertThat(targetIdeInfo.getDependenciesList()).contains("//com/google/example:lib");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(2);
    assertThat(relativePathsForPySourcesOf(targetIdeInfo)).containsExactly("com/google/example/test.py");
    assertThat(targetIdeInfo.hasPyIdeInfo()).isTrue();
    assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/test.py", "com/google/example/lib.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 4 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testPackageManifestCreated.

@Test
public void testPackageManifestCreated() 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 packageManifest = targetIdeInfo.getJavaIdeInfo().getPackageManifest();
    assertNotNull(packageManifest);
    assertEquals(packageManifest.getRelativePath(), "com/google/example/simple.manifest");
}
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 5 with ArtifactLocation

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

the class AndroidStudioInfoAspectTest method testSimplePyTest.

@Test
public void testSimplePyTest() throws Exception {
    scratch.file("com/google/example/BUILD", "py_test(", "    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_test");
    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)19 Test (org.junit.Test)17 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 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 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