Search in sources :

Example 1 with RemoteOutputArtifact

use of com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact in project intellij by bazelbuild.

the class RemoteOutputsCacheTest method testExtensionOnly.

@Test
public void testExtensionOnly() {
    RemoteOutputArtifact artifact = mock(RemoteOutputArtifact.class);
    when(artifact.getKey()).thenReturn("k8-opt/foo/bar/.bazelrc");
    assertThat(RemoteOutputsCache.getCacheKey(artifact)).isEqualTo("_764d6d66.bazelrc");
}
Also used : RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) Test(org.junit.Test)

Example 2 with RemoteOutputArtifact

use of com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact in project intellij by bazelbuild.

the class RemoteOutputsCacheTest method testWindowsStylePath.

@Test
public void testWindowsStylePath() {
    RemoteOutputArtifact artifact = mock(RemoteOutputArtifact.class);
    when(artifact.getKey()).thenReturn("k8-opt\\foo\\bar\\foo.bar");
    assertThat(RemoteOutputsCache.getCacheKey(artifact)).isEqualTo("foo_2a410243.bar");
}
Also used : RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) Test(org.junit.Test)

Example 3 with RemoteOutputArtifact

use of com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact in project intellij by bazelbuild.

the class RemoteOutputsCacheTest method testNoExtension.

@Test
public void testNoExtension() {
    RemoteOutputArtifact artifact = mock(RemoteOutputArtifact.class);
    when(artifact.getKey()).thenReturn("k8-opt/include/vector");
    assertThat(RemoteOutputsCache.getCacheKey(artifact)).isEqualTo("vector_4d304806");
}
Also used : RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) Test(org.junit.Test)

Example 4 with RemoteOutputArtifact

use of com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact in project intellij by bazelbuild.

the class RemoteOutputsCacheTest method testNormalExtension.

@Test
public void testNormalExtension() {
    RemoteOutputArtifact artifact = mock(RemoteOutputArtifact.class);
    when(artifact.getKey()).thenReturn("k8-opt/foo/bar/SourceFile.java");
    assertThat(RemoteOutputsCache.getCacheKey(artifact)).isEqualTo("SourceFile_827b9898.java");
}
Also used : RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) Test(org.junit.Test)

Example 5 with RemoteOutputArtifact

use of com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact in project intellij by bazelbuild.

the class BlazePyResolverUtils method resolveGenfilesPath.

/**
 * Resolves a genfiles-relative path to a locally-accessible file.
 */
private static Optional<File> resolveGenfilesPath(Project project, String relativePath) {
    BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (projectData == null) {
        return Optional.empty();
    }
    // first look for remote output artifacts
    // TODO(brendandouglas): add a common solution handling both remote and local outputs
    RemoteOutputArtifacts remotes = RemoteOutputArtifacts.fromProjectData(projectData);
    RemoteOutputArtifact artifact = remotes.resolveGenfilesPath(relativePath);
    if (artifact == null) {
        artifact = remotes.resolveGenfilesPath(relativePath + ".py");
    }
    if (artifact != null) {
        return Optional.ofNullable(OutputArtifactResolver.resolve(project, artifact));
    }
    return Optional.of(new File(projectData.getBlazeInfo().getGenfilesDirectory(), relativePath));
}
Also used : RemoteOutputArtifact(com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) RemoteOutputArtifacts(com.google.idea.blaze.base.model.RemoteOutputArtifacts) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

RemoteOutputArtifact (com.google.idea.blaze.base.command.buildresult.RemoteOutputArtifact)14 Test (org.junit.Test)8 File (java.io.File)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 BlazeArtifact (com.google.idea.blaze.base.command.buildresult.BlazeArtifact)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 Joiner (com.google.common.base.Joiner)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Futures (com.google.common.util.concurrent.Futures)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 Common (com.google.devtools.intellij.aspect.Common)1 JavaSourcePackage (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaSourcePackage)1 PackageManifest (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.PackageManifest)1 FutureUtil (com.google.idea.blaze.base.async.FutureUtil)1