File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
lib/src/scalafmt/java/com/diffplug/spotless/glue/scalafmt Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 21
21
import java .nio .file .Files ;
22
22
23
23
import org .scalafmt .Scalafmt ;
24
+ import org .scalafmt .Versions ;
24
25
import org .scalafmt .config .ScalafmtConfig ;
25
26
import org .scalafmt .config .ScalafmtConfig$ ;
26
27
@@ -45,6 +46,16 @@ public ScalafmtFormatterFunc(FileSignature configSignature) throws Exception {
45
46
String configStr = new String (Files .readAllBytes (file .toPath ()), StandardCharsets .UTF_8 );
46
47
config = Scalafmt .parseHoconConfig (configStr ).get ();
47
48
}
49
+
50
+ // This check is to raise awareness to the user that the version of the config file is currently not used.
51
+ // Context: https://github.com/diffplug/spotless/issues/2460
52
+ // This check should be removed when Spotless dynamically loads the proper version of the Scalafmt library.
53
+ String scalafmtLibraryVersion = Versions .version ();
54
+ if (!config .version ().equals (scalafmtLibraryVersion )) {
55
+ throw new IllegalArgumentException (
56
+ "Spotless is using " + scalafmtLibraryVersion + " but the config file declares " + config .version () +
57
+ ". Both must match. Update the version declared in the plugin's settings and/or the config file." );
58
+ }
48
59
}
49
60
50
61
@ Override
You can’t perform that action at this time.
0 commit comments