Automatic Remove Ref:org.junit.rules.TemporaryFolder
@@ -56,7 +56,6 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.inject.Inject;
-import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -77,9 +76,6 @@ public final class DesugarRule implements TestRule {
private final Path androidRuntimeJar;
private final Path jacocoAgentJar;
- /** For hosting desugared jar temporarily. */
- private final TemporaryFolder temporaryFolder = new TemporaryFolder();
-
private final Object testInstance;
private final MethodHandles.Lookup testInstanceLookup;
@@ -176,8 +172,7 @@ public final class DesugarRule implements TestRule {
@Override
public Statement apply(Statement base, Description description) {
- return temporaryFolder.apply(
- new Statement() {
+ return new Statement() {
@Override
public void evaluate() throws Throwable {
ImmutableList<Path> transInputs = inputs;
@@ -185,7 +180,6 @@ public final class DesugarRule implements TestRule {
ImmutableList<Path> transOutputs =
getRuntimeOutputPaths(
transInputs,
- temporaryFolder,
tempDirs,
/* outputRootPrefix= */ DEFAULT_OUTPUT_ROOT_PREFIX + "_" + round);
JarTransformationRecord transformationRecord =
@@ -254,8 +248,7 @@ public final class DesugarRule implements TestRule {
}
base.evaluate();
}
- },
- description);
+ };
}
private static void fillMissingClassMemberDescriptorRepo(
@@ -563,10 +556,7 @@ public final class DesugarRule implements TestRule {
}
private static ImmutableList<Path> getRuntimeOutputPaths(
- ImmutableList<Path> inputs,
- TemporaryFolder temporaryFolder,
- Map<String, Path> tempDirs,
- String outputRootPrefix)
+ ImmutableList<Path> inputs, Map<String, Path> tempDirs, String outputRootPrefix)
throws IOException {
ImmutableList.Builder<Path> outputRuntimePathsBuilder = ImmutableList.builder();
for (Path path : inputs) {
@@ -575,7 +565,9 @@ public final class DesugarRule implements TestRule {
if (tempDirs.containsKey(targetDirKey)) {
outputDirPath = tempDirs.get(targetDirKey);
} else {
- outputDirPath = Paths.get(temporaryFolder.newFolder(targetDirKey.split("/")).getPath());
+ Path root = Files.createTempDirectory("junit");
+ Files.delete(root);
+ outputDirPath = Files.createDirectories(root.resolve(Paths.get(targetDirKey)));
tempDirs.put(targetDirKey, outputDirPath);
}
outputRuntimePathsBuilder.add(outputDirPath.resolve(path.getFileName()));
@@ -597,5 +589,4 @@ public final class DesugarRule implements TestRule {
}
return fields.build();
}
-
}
