@@ -191,18 +191,21 @@ private static String resolveNameAgainstPath(String name) throws IOException, In
191191 /**
192192 * Checks the Biome config path. When the config path does not exist or when it
193193 * does not contain a file named {@code biome.json}, an error is thrown.
194+ * @param configPath The path to validate.
195+ * @param version The version of Biome.
194196 */
195- private static void validateBiomeConfigPath (String configPath ) {
197+ private static void validateBiomeConfigPath (String configPath , String version ) {
196198 if (configPath == null ) {
197199 return ;
198200 }
201+ var atLeastV2 = BiomeSettings .versionHigherThanOrEqualTo (version , 2 , 0 , 0 );
199202 var path = Paths .get (configPath );
200- var config = path .resolve (BiomeSettings .configName ());
203+ var configFile = Files . isRegularFile ( path ) && atLeastV2 ? path : path .resolve (BiomeSettings .configName ());
201204 if (!Files .exists (path )) {
202205 throw new IllegalArgumentException ("Biome config directory does not exist: " + path );
203206 }
204- if (!Files .exists (config )) {
205- throw new IllegalArgumentException ("Biome config does not exist: " + config );
207+ if (!Files .exists (configFile )) {
208+ throw new IllegalArgumentException ("Biome config does not exist: " + configFile );
206209 }
207210 }
208211
@@ -240,11 +243,10 @@ public FormatterStep create() {
240243 }
241244
242245 /**
243- * Sets the path to the directory with the {@code biome.json} config file. When
244- * no config path is set, the default configuration is used.
246+ * Sets the path to the Biome configuration. Must be either a directory with a file named {@code biome.json}, or
247+ * a file with the Biome config as JSON. When no config path is set, the default configuration is used.
245248 *
246- * @param configPath Config path to use. Must point to a directory which contains
247- * a file named {@code biome.json}.
249+ * @param configPath Config path to use.
248250 * @return This builder instance for chaining method calls.
249251 */
250252 public BiomeStep withConfigPath (String configPath ) {
@@ -296,7 +298,7 @@ public BiomeStep withLanguage(String language) {
296298 private State createState () throws IOException , InterruptedException {
297299 var resolvedPathToExe = resolveExe ();
298300 validateBiomeExecutable (resolvedPathToExe );
299- validateBiomeConfigPath (configPath );
301+ validateBiomeConfigPath (configPath , version );
300302 logger .debug ("Using Biome executable located at '{}'" , resolvedPathToExe );
301303 var exeSignature = FileSignature .signAsList (Collections .singleton (new File (resolvedPathToExe )));
302304 makeExecutable (resolvedPathToExe );
0 commit comments