Skip to content

Commit

Permalink
Better support for incremental builds
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Mar 24, 2020
1 parent 84bcb15 commit 17d5cd9
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -72,7 +73,7 @@ public boolean isIncremental() {
}

@Override
public void transform(final @NotNull TransformInvocation transformInvocation) {
public void transform(final @NotNull TransformInvocation transformInvocation) throws IOException {
final Stream<File> depsStream = Stream.concat(
transformInvocation.getReferencedInputs().stream().map(TransformInput::getJarInputs),
transformInvocation.getReferencedInputs().stream().map(TransformInput::getDirectoryInputs))
Expand All @@ -98,6 +99,10 @@ public void transform(final @NotNull TransformInvocation transformInvocation) {
final MethodMap methodMap = new MethodMap();
backports.forEach(backport -> backport.map(typeMap, methodMap));

if (!transformInvocation.isIncremental()) {
transformInvocation.getOutputProvider().deleteAll();
}

transformInvocation.getInputs().forEach(transformInput -> {
transformInput.getDirectoryInputs().forEach(Lambdas.consumer(directoryInput -> {
final File outputDir = transformInvocation.getOutputProvider().getContentLocation(
Expand Down Expand Up @@ -149,6 +154,9 @@ public void transform(final @NotNull TransformInvocation transformInvocation) {
}
FileUtils.deleteRecursivelyIfExists(outputDir);
FileUtils.deleteIfExists(outputJar);
if (jarInput.getStatus() == Status.REMOVED) {
return;
}
if (!outputDir.mkdirs()) {
throw new RuntimeException("Could not create output directory");
}
Expand Down

0 comments on commit 17d5cd9

Please sign in to comment.