1
1
/*
2
- * Copyright 2021 DiffPlug
2
+ * Copyright 2021-2022 DiffPlug
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
18
18
import java .io .IOException ;
19
19
import java .io .UncheckedIOException ;
20
+ import java .util .ArrayList ;
20
21
import java .util .Base64 ;
22
+ import java .util .List ;
21
23
import java .util .Objects ;
22
24
25
+ import org .apache .maven .model .Dependency ;
23
26
import org .apache .maven .model .Plugin ;
24
27
import org .apache .maven .project .MavenProject ;
25
28
@@ -77,6 +80,10 @@ public String toString() {
77
80
}
78
81
79
82
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 ));
80
87
try (ObjectDigestOutputStream out = ObjectDigestOutputStream .create ()) {
81
88
out .writeObject (plugin );
82
89
for (Formatter formatter : formatters ) {
@@ -86,6 +93,9 @@ private static byte[] digest(Plugin plugin, Iterable<Formatter> formatters) {
86
93
return out .digest ();
87
94
} catch (IOException e ) {
88
95
throw new UncheckedIOException ("Unable to serialize plugin " + plugin , e );
96
+ } finally {
97
+ // reset the original list
98
+ plugin .setDependencies (dependencies );
89
99
}
90
100
}
91
101
}
0 commit comments