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 2121import java .nio .file .Files ;
2222
2323import org .scalafmt .Scalafmt ;
24+ import org .scalafmt .Versions ;
2425import org .scalafmt .config .ScalafmtConfig ;
2526import org .scalafmt .config .ScalafmtConfig$ ;
2627
@@ -45,6 +46,16 @@ public ScalafmtFormatterFunc(FileSignature configSignature) throws Exception {
4546 String configStr = new String (Files .readAllBytes (file .toPath ()), StandardCharsets .UTF_8 );
4647 config = Scalafmt .parseHoconConfig (configStr ).get ();
4748 }
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+ }
4859 }
4960
5061 @ Override
You can’t perform that action at this time.
0 commit comments