diff --git a/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java b/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java index 1b70815eea..3d0532eca7 100644 --- a/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java +++ b/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java @@ -263,7 +263,9 @@ public void indentWithTabs() { * Spotless will look for a line that starts with this to know what the "top" is. */ public void licenseHeader(String licenseHeader, String delimiter) { - customLazy(LicenseHeaderStep.NAME, () -> new LicenseHeaderStep(licenseHeader, delimiter)::format); + steps.add(FormatterStep.create(LicenseHeaderStep.NAME, + new LicenseHeaderStep(licenseHeader, delimiter), + LicenseHeaderStep::format)); } /** @@ -273,7 +275,9 @@ public void licenseHeader(String licenseHeader, String delimiter) { * Spotless will look for a line that starts with this to know what the "top" is. */ public void licenseHeaderFile(Object licenseHeaderFile, String delimiter) { - customLazy(LicenseHeaderStep.NAME, () -> new LicenseHeaderStep(getProject().file(licenseHeaderFile), getEncoding(), delimiter)::format); + steps.add(FormatterStep.createLazy(LicenseHeaderStep.NAME, + () -> new LicenseHeaderStep(getProject().file(licenseHeaderFile), getEncoding(), delimiter), + LicenseHeaderStep::format)); } /** Sets up a format task according to the values in this extension. */ diff --git a/src/main/java/com/diffplug/gradle/spotless/LicenseHeaderStep.java b/src/main/java/com/diffplug/gradle/spotless/LicenseHeaderStep.java index f186859249..a82fe511a8 100644 --- a/src/main/java/com/diffplug/gradle/spotless/LicenseHeaderStep.java +++ b/src/main/java/com/diffplug/gradle/spotless/LicenseHeaderStep.java @@ -17,6 +17,7 @@ import java.io.File; import java.io.IOException; +import java.io.Serializable; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -26,7 +27,9 @@ import org.gradle.api.GradleException; /** Prefixes a license header before the package statement. */ -public class LicenseHeaderStep { +public class LicenseHeaderStep implements Serializable { + private static final long serialVersionUID = 1L; + public static final String NAME = "LicenseHeader"; private final String license;