diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/ArFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/ArFunction.java index c9104c0a265bf6..2f981be745c1cc 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/ArFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/ArFunction.java @@ -58,7 +58,7 @@ public Path decompress(DecompressorDescriptor descriptor) while ((entry = arStream.getNextArEntry()) != null) { String entryName = entry.getName(); entryName = renameFiles.getOrDefault(entryName, entryName); - Path filePath = descriptor.repositoryPath().getRelative(entryName); + Path filePath = descriptor.destinationPath().getRelative(entryName); filePath.getParentDirectory().createDirectoryAndParents(); if (entry.isDirectory()) { // ar archives don't contain any directory information, so this should never @@ -81,6 +81,6 @@ public Path decompress(DecompressorDescriptor descriptor) } } - return descriptor.repositoryPath(); + return descriptor.destinationPath(); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/BUILD b/src/main/java/com/google/devtools/build/lib/bazel/repository/BUILD index 49c599a49c5d1d..c96dab6b5c3726 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/BUILD +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/BUILD @@ -51,6 +51,7 @@ java_library( "//src/main/java/com/google/devtools/common/options", "//src/main/java/net/starlark/java/eval", "//third_party:apache_commons_compress", + "//third_party:auto_value", "//third_party:flogger", "//third_party:guava", "//third_party:java-diff-utils", diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java index a76084b808008a..f38e7d56894ac2 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunction.java @@ -74,18 +74,18 @@ public Path decompress(DecompressorDescriptor descriptor) continue; } - Path filePath = descriptor.repositoryPath().getRelative(entryPath.getPathFragment()); + Path filePath = descriptor.destinationPath().getRelative(entryPath.getPathFragment()); filePath.getParentDirectory().createDirectoryAndParents(); if (entry.isDirectory()) { filePath.createDirectoryAndParents(); } else { if (entry.isSymbolicLink() || entry.isLink()) { PathFragment targetName = PathFragment.create(entry.getLinkName()); - targetName = maybeDeprefixSymlink(targetName, prefix, descriptor.repositoryPath()); + targetName = maybeDeprefixSymlink(targetName, prefix, descriptor.destinationPath()); if (entry.isSymbolicLink()) { symlinks.put(filePath, targetName); } else { - Path targetPath = descriptor.repositoryPath().getRelative(targetName); + Path targetPath = descriptor.destinationPath().getRelative(targetName); if (filePath.equals(targetPath)) { // The behavior here is semantically different, depending on whether the underlying // filesystem is case-sensitive or case-insensitive. However, it is effectively the @@ -133,6 +133,6 @@ public Path decompress(DecompressorDescriptor descriptor) } } - return descriptor.repositoryPath(); + return descriptor.destinationPath(); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java index acb31b3acfbd3a..2676fdba14d091 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorDescriptor.java @@ -14,193 +14,47 @@ package com.google.devtools.build.lib.bazel.repository; +import com.google.auto.value.AutoValue; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; -import com.google.devtools.build.lib.bazel.repository.DecompressorValue.Decompressor; -import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException; import com.google.devtools.build.lib.vfs.Path; -import com.google.errorprone.annotations.CanIgnoreReturnValue; -import java.util.Collections; import java.util.Map; -import java.util.Objects; -import javax.annotation.Nullable; - -/** - * Description of an archive to be decompressed. - * TODO(bazel-team): this should be an autovalue class. - */ -public class DecompressorDescriptor { - private final String targetKind; - private final String targetName; - private final Path archivePath; - private final Path repositoryPath; - private final Optional prefix; - private final boolean executable; - private final Map renameFiles; - private final Decompressor decompressor; - - private DecompressorDescriptor( - String targetKind, - String targetName, - Path archivePath, - Path repositoryPath, - @Nullable String prefix, - boolean executable, - Map renameFiles, - Decompressor decompressor) { - this.targetKind = targetKind; - this.targetName = targetName; - this.archivePath = archivePath; - this.repositoryPath = repositoryPath; - this.prefix = Optional.fromNullable(prefix); - this.executable = executable; - this.renameFiles = renameFiles; - this.decompressor = decompressor; - } - public String targetKind() { - return targetKind; - } +/** Description of an archive to be decompressed. */ +@AutoValue +public abstract class DecompressorDescriptor { - public String targetName() { - return targetName; - } + /** The context in which this decompression is happening. Should only be used for reporting. */ + public abstract String context(); - public Path archivePath() { - return archivePath; - } + public abstract Path archivePath(); - public Path repositoryPath() { - return repositoryPath; - } + public abstract Path destinationPath(); - public Optional prefix() { - return prefix; - } + public abstract Optional prefix(); - public boolean executable() { - return executable; - } + public abstract ImmutableMap renameFiles(); - public Map renameFiles() { - return renameFiles; + public static Builder builder() { + return new AutoValue_DecompressorDescriptor.Builder() + .setContext("") + .setRenameFiles(ImmutableMap.of()); } - public Decompressor getDecompressor() { - return decompressor; - } + /** Builder for describing the file to be decompressed. */ + @AutoValue.Builder + public abstract static class Builder { - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof DecompressorDescriptor)) { - return false; - } - - DecompressorDescriptor descriptor = (DecompressorDescriptor) other; - return Objects.equals(targetKind, descriptor.targetKind) - && Objects.equals(targetName, descriptor.targetName) - && Objects.equals(archivePath, descriptor.archivePath) - && Objects.equals(repositoryPath, descriptor.repositoryPath) - && Objects.equals(prefix, descriptor.prefix) - && Objects.equals(executable, descriptor.executable) - && Objects.equals(renameFiles, descriptor.renameFiles) - && decompressor == descriptor.decompressor; - } + public abstract Builder setContext(String context); - @Override - public int hashCode() { - return Objects.hash(targetKind, targetName, archivePath, repositoryPath, prefix, renameFiles); - } + public abstract Builder setArchivePath(Path archivePath); - public static Builder builder() { - return new Builder(); - } + public abstract Builder setDestinationPath(Path destinationPath); + + public abstract Builder setPrefix(String prefix); + + public abstract Builder setRenameFiles(Map renameFiles); - /** - * Builder for describing the file to be decompressed. The fields set will depend on the type - * of file. - */ - public static class Builder { - private String targetKind; - private String targetName; - private Path archivePath; - private Path repositoryPath; - private String prefix; - private boolean executable; - private Map renameFiles; - private Decompressor decompressor; - - private Builder() { - } - - public DecompressorDescriptor build() throws RepositoryFunctionException { - if (decompressor == null) { - decompressor = DecompressorValue.getDecompressor(archivePath); - } - if (renameFiles == null) { - renameFiles = Collections.emptyMap(); - } - return new DecompressorDescriptor( - targetKind, - targetName, - archivePath, - repositoryPath, - prefix, - executable, - renameFiles, - decompressor); - } - - @CanIgnoreReturnValue - public Builder setTargetKind(String targetKind) { - this.targetKind = targetKind; - return this; - } - - @CanIgnoreReturnValue - public Builder setTargetName(String targetName) { - this.targetName = targetName; - return this; - } - - @CanIgnoreReturnValue - public Builder setArchivePath(Path archivePath) { - this.archivePath = archivePath; - return this; - } - - @CanIgnoreReturnValue - public Builder setRepositoryPath(Path repositoryPath) { - this.repositoryPath = repositoryPath; - return this; - } - - @CanIgnoreReturnValue - public Builder setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - @CanIgnoreReturnValue - public Builder setExecutable(boolean executable) { - this.executable = executable; - return this; - } - - @CanIgnoreReturnValue - public Builder setRenameFiles(Map renameFiles) { - this.renameFiles = ImmutableMap.copyOf(renameFiles); - return this; - } - - @CanIgnoreReturnValue - public Builder setDecompressor(Decompressor decompressor) { - this.decompressor = decompressor; - return this; - } + public abstract DecompressorDescriptor build(); } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java index a651c2cd921325..82e3dcf747f21b 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/DecompressorValue.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.bazel.repository; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException; import com.google.devtools.build.lib.vfs.Path; @@ -89,8 +90,8 @@ public int hashCode() { return directory.hashCode(); } - static Decompressor getDecompressor(Path archivePath) - throws RepositoryFunctionException { + @VisibleForTesting + static Decompressor getDecompressor(Path archivePath) throws RepositoryFunctionException { String baseName = archivePath.getBaseName(); if (baseName.endsWith(".zip") || baseName.endsWith(".jar") @@ -122,7 +123,7 @@ static Decompressor getDecompressor(Path archivePath) public static Path decompress(DecompressorDescriptor descriptor) throws RepositoryFunctionException, InterruptedException { try { - return descriptor.getDecompressor().decompress(descriptor); + return getDecompressor(descriptor.archivePath()).decompress(descriptor); } catch (IOException e) { Path destinationDirectory = descriptor.archivePath().getParentDirectory(); throw new RepositoryFunctionException( diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java index 21059434de1c2a..8990e7c4c08e64 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressor.java @@ -58,8 +58,8 @@ private ZipDecompressor() { @VisibleForTesting static final int WINDOWS_FILE_ATTRIBUTE_NORMAL = 0x80; /** - * This unzips the zip file to directory {@link DecompressorDescriptor#repositoryPath()}, which by - * default is empty relative [to the calling external repository rule] path. The zip file is + * This unzips the zip file to directory {@link DecompressorDescriptor#destinationPath()}, which + * by default is empty relative [to the calling external repository rule] path. The zip file is * expected to have the WORKSPACE file at the top level, e.g.: * *
@@ -77,7 +77,7 @@ private ZipDecompressor() {
   @Nullable
   public Path decompress(DecompressorDescriptor descriptor)
       throws IOException, InterruptedException {
-    Path destinationDirectory = descriptor.repositoryPath();
+    Path destinationDirectory = descriptor.destinationPath();
     Optional prefix = descriptor.prefix();
     Map renameFiles = descriptor.renameFiles();
     boolean foundPrefix = false;
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContext.java
index c9a54274eca034..5728e16926618b 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContext.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/starlark/StarlarkRepositoryContext.java
@@ -797,10 +797,9 @@ public void extract(
                 outputPath.getPath().toString(), "Extracting " + archivePath.getPath()));
     DecompressorValue.decompress(
         DecompressorDescriptor.builder()
-            .setTargetKind(rule.getTargetKind())
-            .setTargetName(rule.getName())
+            .setContext(getIdentifyingStringForLogging())
             .setArchivePath(archivePath.getPath())
-            .setRepositoryPath(outputPath.getPath())
+            .setDestinationPath(outputPath.getPath())
             .setPrefix(stripPrefix)
             .setRenameFiles(renameFilesMap)
             .build());
@@ -1009,10 +1008,9 @@ public StructImpl downloadAndExtract(
               new ExtractProgress(outputPath.getPath().toString(), "Extracting " + downloadedPath));
       DecompressorValue.decompress(
           DecompressorDescriptor.builder()
-              .setTargetKind(rule.getTargetKind())
-              .setTargetName(rule.getName())
+              .setContext(getIdentifyingStringForLogging())
               .setArchivePath(downloadedPath)
-              .setRepositoryPath(outputPath.getPath())
+              .setDestinationPath(outputPath.getPath())
               .setPrefix(stripPrefix)
               .setRenameFiles(renameFilesMap)
               .build());
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/ArFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/ArFunctionTest.java
index 1e09f03d592b6d..5db3857a3f9497 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/ArFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/ArFunctionTest.java
@@ -47,7 +47,7 @@ public class ArFunctionTest {
 
   @Test
   public void testDecompress() throws Exception {
-    Path outputDir = decompress(createDescriptorBuilder());
+    Path outputDir = decompress(createDescriptorBuilder().build());
 
     assertThat(outputDir.exists()).isTrue();
     Path firstFile = outputDir.getRelative(FIRST_FILE_NAME);
@@ -72,16 +72,15 @@ public void testDecompressWithRenamedFiles() throws Exception {
     renameFiles.put("archived_first.txt", "renamed_file.txt");
     DecompressorDescriptor.Builder descriptorBuilder =
         createDescriptorBuilder().setRenameFiles(renameFiles);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     assertThat(outputDir.exists()).isTrue();
     Path renamedFile = outputDir.getRelative("renamed_file.txt");
     assertThat(renamedFile.exists()).isTrue();
   }
 
-  private Path decompress(DecompressorDescriptor.Builder descriptorBuilder) throws Exception {
-    descriptorBuilder.setDecompressor(ArFunction.INSTANCE);
-    return new ArFunction().decompress(descriptorBuilder.build());
+  private Path decompress(DecompressorDescriptor descriptor) throws Exception {
+    return new ArFunction().decompress(descriptor);
   }
 
   private DecompressorDescriptor.Builder createDescriptorBuilder() throws IOException {
@@ -100,6 +99,6 @@ private DecompressorDescriptor.Builder createDescriptorBuilder() throws IOExcept
     Path workingDir = testFS.getPath(new File(TestUtils.tmpDir()).getCanonicalPath());
     Path outDir = workingDir.getRelative("out");
 
-    return DecompressorDescriptor.builder().setRepositoryPath(outDir).setArchivePath(tarballPath);
+    return DecompressorDescriptor.builder().setDestinationPath(outDir).setArchivePath(tarballPath);
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunctionTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunctionTest.java
index fde5a835df00ae..5961e2aad7f665 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/CompressedTarFunctionTest.java
@@ -48,7 +48,7 @@ public void setUpFs() throws Exception {
    */
   @Test
   public void testDecompressWithoutPrefix() throws Exception {
-    Path outputDir = decompress(archiveDescriptor.createDescriptorBuilder());
+    Path outputDir = decompress(archiveDescriptor.createDescriptorBuilder().build());
 
     archiveDescriptor.assertOutputFiles(outputDir, ROOT_FOLDER_NAME, INNER_FOLDER_NAME);
   }
@@ -61,7 +61,7 @@ public void testDecompressWithoutPrefix() throws Exception {
   public void testDecompressWithPrefix() throws Exception {
     DecompressorDescriptor.Builder descriptorBuilder =
         archiveDescriptor.createDescriptorBuilder().setPrefix(ROOT_FOLDER_NAME);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     archiveDescriptor.assertOutputFiles(outputDir, INNER_FOLDER_NAME);
   }
@@ -78,7 +78,7 @@ public void testDecompressWithRenamedFiles() throws Exception {
     renameFiles.put(innerDirName + "/hardLinkFile", innerDirName + "/renamedFile");
     DecompressorDescriptor.Builder descriptorBuilder =
         archiveDescriptor.createDescriptorBuilder().setRenameFiles(renameFiles);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     Path innerDir = outputDir.getRelative(ROOT_FOLDER_NAME).getRelative(INNER_FOLDER_NAME);
     assertThat(innerDir.getRelative("renamedFile").exists()).isTrue();
@@ -96,20 +96,19 @@ public void testDecompressWithRenamedFilesAndPrefix() throws Exception {
             .createDescriptorBuilder()
             .setPrefix(ROOT_FOLDER_NAME)
             .setRenameFiles(renameFiles);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     Path innerDir = outputDir.getRelative(INNER_FOLDER_NAME);
     assertThat(innerDir.getRelative("renamedFile").exists()).isTrue();
   }
 
-  private Path decompress(DecompressorDescriptor.Builder descriptorBuilder) throws Exception {
-    descriptorBuilder.setDecompressor(TarGzFunction.INSTANCE);
+  private Path decompress(DecompressorDescriptor descriptor) throws Exception {
     return new CompressedTarFunction() {
       @Override
       protected InputStream getDecompressorStream(DecompressorDescriptor descriptor)
           throws IOException {
         return new GZIPInputStream(new FileInputStream(descriptor.archivePath().getPathFile()));
       }
-    }.decompress(descriptorBuilder.build());
+    }.decompress(descriptor);
   }
 }
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/DecompressorValueTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/DecompressorValueTest.java
index f457f2b61161d8..8357dc2790df00 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/DecompressorValueTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/DecompressorValueTest.java
@@ -17,6 +17,7 @@
 import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertThrows;
 
+import com.google.devtools.build.lib.bazel.repository.DecompressorValue.Decompressor;
 import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException;
 import com.google.devtools.build.lib.vfs.DigestHashFunction;
 import com.google.devtools.build.lib.vfs.FileSystem;
@@ -37,29 +38,29 @@ public class DecompressorValueTest {
   @Test
   public void testKnownFileExtensionsDoNotThrow() throws Exception {
     Path path = fs.getPath("/foo/.external-repositories/some-repo/bar.zip");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    Decompressor unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.jar");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.zip");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tar.gz");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tgz");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tar.xz");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.txz");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tar.zst");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tzst");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.tar.bz2");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.ar");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
     path = fs.getPath("/foo/.external-repositories/some-repo/bar.baz.deb");
-    DecompressorDescriptor.builder().setArchivePath(path).build();
+    unused = DecompressorValue.getDecompressor(path);
   }
 
   @Test
@@ -67,8 +68,7 @@ public void testUnknownFileExtensionsThrow() throws Exception {
     Path zipPath = fs.getPath("/foo/.external-repositories/some-repo/bar.baz");
     RepositoryFunctionException expected =
         assertThrows(
-            RepositoryFunctionException.class,
-            () -> DecompressorDescriptor.builder().setArchivePath(zipPath).build());
+            RepositoryFunctionException.class, () -> DecompressorValue.getDecompressor(zipPath));
     assertThat(expected).hasMessageThat().contains("Expected a file with a .zip, .jar,");
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/TestArchiveDescriptor.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/TestArchiveDescriptor.java
index 66a8f8098b2b7f..319b93bd29d053 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/TestArchiveDescriptor.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/TestArchiveDescriptor.java
@@ -80,7 +80,7 @@ DecompressorDescriptor.Builder createDescriptorBuilder() throws IOException {
     Path workingDir = testFS.getPath(new File(TestUtils.tmpDir()).getCanonicalPath());
     Path outDir = workingDir.getRelative(outDirName);
 
-    return DecompressorDescriptor.builder().setRepositoryPath(outDir).setArchivePath(tarballPath);
+    return DecompressorDescriptor.builder().setDestinationPath(outDir).setArchivePath(tarballPath);
   }
 
   /** Validate the content of the output directory */
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressorTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressorTest.java
index 3b0f8300768bf4..a1a9d74175699a 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/ZipDecompressorTest.java
@@ -50,7 +50,7 @@ public class ZipDecompressorTest {
   public void testDecompressWithoutPrefix() throws Exception {
     TestArchiveDescriptor archiveDescriptor =
         new TestArchiveDescriptor(ARCHIVE_NAME, "out/inner", false);
-    Path outputDir = decompress(archiveDescriptor.createDescriptorBuilder());
+    Path outputDir = decompress(archiveDescriptor.createDescriptorBuilder().build());
 
     archiveDescriptor.assertOutputFiles(outputDir, ROOT_FOLDER_NAME, INNER_FOLDER_NAME);
   }
@@ -64,7 +64,7 @@ public void testDecompressWithPrefix() throws Exception {
     TestArchiveDescriptor archiveDescriptor = new TestArchiveDescriptor(ARCHIVE_NAME, "out", false);
     DecompressorDescriptor.Builder descriptorBuilder =
         archiveDescriptor.createDescriptorBuilder().setPrefix(ROOT_FOLDER_NAME);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     archiveDescriptor.assertOutputFiles(outputDir, INNER_FOLDER_NAME);
   }
@@ -81,7 +81,7 @@ public void testDecompressWithRenamedFiles() throws Exception {
     renameFiles.put(innerDirName + "/hardLinkFile", innerDirName + "/renamedFile");
     DecompressorDescriptor.Builder descriptorBuilder =
         archiveDescriptor.createDescriptorBuilder().setRenameFiles(renameFiles);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     Path innerDir = outputDir.getRelative(ROOT_FOLDER_NAME).getRelative(INNER_FOLDER_NAME);
     assertThat(innerDir.getRelative("renamedFile").exists()).isTrue();
@@ -100,15 +100,14 @@ public void testDecompressWithRenamedFilesAndPrefix() throws Exception {
             .createDescriptorBuilder()
             .setPrefix(ROOT_FOLDER_NAME)
             .setRenameFiles(renameFiles);
-    Path outputDir = decompress(descriptorBuilder);
+    Path outputDir = decompress(descriptorBuilder.build());
 
     Path innerDir = outputDir.getRelative(INNER_FOLDER_NAME);
     assertThat(innerDir.getRelative("renamedFile").exists()).isTrue();
   }
 
-  private Path decompress(DecompressorDescriptor.Builder descriptorBuilder) throws Exception {
-    descriptorBuilder.setDecompressor(ZipDecompressor.INSTANCE);
-    return ZipDecompressor.INSTANCE.decompress(descriptorBuilder.build());
+  private Path decompress(DecompressorDescriptor descriptor) throws Exception {
+    return ZipDecompressor.INSTANCE.decompress(descriptor);
   }
 
   @Test
diff --git a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/BazelEmbeddedStarlarkBlackBoxTest.java b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/BazelEmbeddedStarlarkBlackBoxTest.java
index 8cc65c6be93baa..ea4324ac8219cb 100644
--- a/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/BazelEmbeddedStarlarkBlackBoxTest.java
+++ b/src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace/BazelEmbeddedStarlarkBlackBoxTest.java
@@ -138,7 +138,7 @@ private Path decompress(Path dataTarPath) throws Exception {
         TarFunction.INSTANCE.decompress(
             DecompressorDescriptor.builder()
                 .setArchivePath(dataTarPathForDecompress)
-                .setRepositoryPath(dataTarPathForDecompress.getParentDirectory())
+                .setDestinationPath(dataTarPathForDecompress.getParentDirectory())
                 .build());
     return Paths.get(directory.getPathString());
   }