@@ -191,18 +191,21 @@ private static String resolveNameAgainstPath(String name) throws IOException, In
191
191
/**
192
192
* Checks the Biome config path. When the config path does not exist or when it
193
193
* 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.
194
196
*/
195
- private static void validateBiomeConfigPath (String configPath ) {
197
+ private static void validateBiomeConfigPath (String configPath , String version ) {
196
198
if (configPath == null ) {
197
199
return ;
198
200
}
201
+ var atLeastV2 = BiomeSettings .versionHigherThanOrEqualTo (version , 2 , 0 , 0 );
199
202
var path = Paths .get (configPath );
200
- var config = path .resolve (BiomeSettings .configName ());
203
+ var configFile = Files . isRegularFile ( path ) && atLeastV2 ? path : path .resolve (BiomeSettings .configName ());
201
204
if (!Files .exists (path )) {
202
205
throw new IllegalArgumentException ("Biome config directory does not exist: " + path );
203
206
}
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 );
206
209
}
207
210
}
208
211
@@ -240,11 +243,10 @@ public FormatterStep create() {
240
243
}
241
244
242
245
/**
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.
245
248
*
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.
248
250
* @return This builder instance for chaining method calls.
249
251
*/
250
252
public BiomeStep withConfigPath (String configPath ) {
@@ -296,7 +298,7 @@ public BiomeStep withLanguage(String language) {
296
298
private State createState () throws IOException , InterruptedException {
297
299
var resolvedPathToExe = resolveExe ();
298
300
validateBiomeExecutable (resolvedPathToExe );
299
- validateBiomeConfigPath (configPath );
301
+ validateBiomeConfigPath (configPath , version );
300
302
logger .debug ("Using Biome executable located at '{}'" , resolvedPathToExe );
301
303
var exeSignature = FileSignature .signAsList (Collections .singleton (new File (resolvedPathToExe )));
302
304
makeExecutable (resolvedPathToExe );
0 commit comments