diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineImmutables.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineImmutables.java index 9fbfb9b1d..2ac5911b6 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineImmutables.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineImmutables.java @@ -24,6 +24,7 @@ import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.process.CommandLineArgumentProvider; public final class BaselineImmutables implements Plugin { @@ -36,12 +37,16 @@ public void apply(Project project) { .get() .getOptions() .getCompilerArgumentProviders() - .add(() -> { - if (hasImmutablesProcessor(project, sourceSet)) { - return Collections.singletonList("-Aimmutables.gradle.incremental"); - } + // Use an anonymous class because tasks with lambda inputs cannot be cached + .add(new CommandLineArgumentProvider() { + @Override + public Iterable asArguments() { + if (hasImmutablesProcessor(project, sourceSet)) { + return Collections.singletonList("-Aimmutables.gradle.incremental"); + } - return Collections.emptyList(); + return Collections.emptyList(); + } }); }); });