Skip to content

Commit c2df929

Browse files
committed
Fix PluginFingerprint for plugin with dependencies
Fixes #1073
1 parent 59051ff commit c2df929

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/PluginFingerprint.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,9 +17,12 @@
1717

1818
import java.io.IOException;
1919
import java.io.UncheckedIOException;
20+
import java.util.ArrayList;
2021
import java.util.Base64;
22+
import java.util.List;
2123
import java.util.Objects;
2224

25+
import org.apache.maven.model.Dependency;
2326
import org.apache.maven.model.Plugin;
2427
import org.apache.maven.project.MavenProject;
2528

@@ -77,6 +80,10 @@ public String toString() {
7780
}
7881

7982
private static byte[] digest(Plugin plugin, Iterable<Formatter> formatters) {
83+
List<Dependency> dependencies = plugin.getDependencies();
84+
// dependencies can be an unserializable org.apache.maven.model.merge.ModelMerger$MergingList
85+
// replace it with a serializable ArrayList
86+
plugin.setDependencies(new ArrayList<>(dependencies));
8087
try (ObjectDigestOutputStream out = ObjectDigestOutputStream.create()) {
8188
out.writeObject(plugin);
8289
for (Formatter formatter : formatters) {
@@ -86,6 +93,9 @@ private static byte[] digest(Plugin plugin, Iterable<Formatter> formatters) {
8693
return out.digest();
8794
} catch (IOException e) {
8895
throw new UncheckedIOException("Unable to serialize plugin " + plugin, e);
96+
} finally {
97+
// reset the original list
98+
plugin.setDependencies(dependencies);
8999
}
90100
}
91101
}

0 commit comments

Comments
 (0)