Skip to content

Commit 9ed6289

Browse files
committed
Remove BiomeFlavor enum
We only support biome (not rome) anymore, so the enum serves no purpose.
1 parent 2d32ccd commit 9ed6289

File tree

16 files changed

+80
-133
lines changed

16 files changed

+80
-133
lines changed

lib/src/main/java/com/diffplug/spotless/biome/BiomeExecutableDownloader.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,13 @@ final class BiomeExecutableDownloader {
7171

7272
private final Path downloadDir;
7373

74-
private final BiomeFlavor flavor;
75-
7674
/**
7775
* Creates a new downloader for the Biome executable. The executable files are
7876
* stored in the given download directory.
7977
*
80-
* @param flavor Flavor of Biome to use.
8178
* @param downloadDir Directory where to store the downloaded executable.
8279
*/
83-
public BiomeExecutableDownloader(BiomeFlavor flavor, Path downloadDir) {
84-
this.flavor = flavor;
80+
public BiomeExecutableDownloader(Path downloadDir) {
8581
this.downloadDir = downloadDir;
8682
}
8783

@@ -240,7 +236,7 @@ private String computeChecksum(Path file, String algorithm) throws IOException {
240236
* Finds the code name for the given operating system used by the Biome
241237
* executable download URL.
242238
*
243-
* @param os Desired operating system.
239+
* @param architecture Desired operating system architecture.
244240
* @return Code name for the Biome download URL.
245241
* @throws IOException When the given OS is not supported by Biome.
246242
*/

lib/src/main/java/com/diffplug/spotless/biome/BiomeFlavor.java renamed to lib/src/main/java/com/diffplug/spotless/biome/BiomeSettings.java

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,38 @@
1616
package com.diffplug.spotless.biome;
1717

1818
/**
19-
* The flavor of Biome to use. Exists for compatibility reason, may be removed
20-
* shortly.
21-
* <p>
22-
* Will be removed once the old Rome project is not supported anymore.
19+
* Settings and constants for Biome to use.
2320
*/
24-
public enum BiomeFlavor {
25-
/** The new forked Biome project. */
26-
BIOME("biome", "1.2.0", "biome.json", "biome-%s-%s-%s",
27-
"https://github.com/biomejs/biome/releases/download/cli%%2Fv%s/biome-%s");
21+
public final class BiomeSettings {
22+
private final static String configName= "biome.json";
23+
private final static String defaultVersion = "1.2.0";
24+
private final static String downloadFilePattern = "biome-%s-%s-%s";
25+
private final static String shortName = "biome";
26+
private final static String urlPattern = "https://github.com/biomejs/biome/releases/download/cli%%2Fv%s/biome-%s";
2827

29-
private final String configName;
30-
private final String defaultVersion;
31-
private final String downloadFilePattern;
32-
private final String shortName;
33-
private final String urlPattern;
34-
35-
BiomeFlavor(String shortName, String defaultVersion, String configName, String downloadFilePattern,
36-
String urlPattern) {
37-
this.shortName = shortName;
38-
this.defaultVersion = defaultVersion;
39-
this.configName = configName;
40-
this.downloadFilePattern = downloadFilePattern;
41-
this.urlPattern = urlPattern;
42-
}
28+
private BiomeSettings() {}
4329

4430
/**
4531
* @return The name of the default config file.
4632
*/
47-
public String configName() {
33+
public static String configName() {
4834
return configName;
4935
}
5036

5137
/**
5238
* @return Default version to use when no version was set explicitly.
5339
*/
54-
public String defaultVersion() {
40+
public static String defaultVersion() {
5541
return defaultVersion;
5642
}
5743

5844
/**
5945
* @return The pattern for {@link String#format(String, Object...)
6046
* String.format()} for the file name of a Biome executable for a
61-
* certain version and architecure. The first parameter is the platform,
47+
* certain version and architecture. The first parameter is the platform,
6248
* the second is the OS, the third is the architecture.
6349
*/
64-
public String getDownloadFilePattern() {
50+
public static String getDownloadFilePattern() {
6551
return downloadFilePattern;
6652
}
6753

@@ -71,15 +57,14 @@ public String getDownloadFilePattern() {
7157
* The first parameter is the version, the second parameter is the OS /
7258
* platform.
7359
*/
74-
public String getUrlPattern() {
60+
public static String getUrlPattern() {
7561
return urlPattern;
7662
}
7763

7864
/**
79-
* @return The short name of this flavor, i.e. <code>rome</code> or
80-
* <code>biome</code>.
65+
* @return The short name of this flavor, e.g. <code>biome</code>.
8166
*/
82-
public String shortName() {
67+
public static String shortName() {
8368
return shortName;
8469
}
8570
}

lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ public class BiomeStep {
7272
*/
7373
private String language;
7474

75-
/**
76-
* Biome flavor to use. Will be removed once we stop supporting the deprecated Rome project.
77-
*/
78-
@Deprecated
79-
private final BiomeFlavor flavor;
80-
8175
/**
8276
* Path to the Biome executable. Can be <code>null</code>, but either a path to
8377
* the executable of a download directory and version must be given. The path
@@ -103,32 +97,30 @@ public class BiomeStep {
10397
* @return The name of this format step, i.e. <code>biome</code> or <code>rome</code>.
10498
*/
10599
public String name() {
106-
return flavor.shortName();
100+
return BiomeSettings.shortName();
107101
}
108102

109103
/**
110104
* Creates a Biome step that format code by downloading to the given Biome
111105
* version. The executable is downloaded from the network.
112106
*
113-
* @param flavor Flavor of Biome to use.
114107
* @param version Version of the Biome executable to download.
115108
* @param downloadDir Directory where to place the downloaded executable.
116109
* @return A new Biome step that download the executable from the network.
117110
*/
118-
public static BiomeStep withExeDownload(BiomeFlavor flavor, String version, String downloadDir) {
119-
return new BiomeStep(flavor, version, null, downloadDir);
111+
public static BiomeStep withExeDownload(String version, String downloadDir) {
112+
return new BiomeStep(version, null, downloadDir);
120113
}
121114

122115
/**
123116
* Creates a Biome step that formats code by delegating to the Biome executable
124117
* located at the given path.
125118
*
126-
* @param flavor Flavor of Biome to use.
127119
* @param pathToExe Path to the Biome executable to use.
128120
* @return A new Biome step that format with the given executable.
129121
*/
130-
public static BiomeStep withExePath(BiomeFlavor flavor, String pathToExe) {
131-
return new BiomeStep(flavor, null, pathToExe, null);
122+
public static BiomeStep withExePath(String pathToExe) {
123+
return new BiomeStep(null, pathToExe, null);
132124
}
133125

134126
/**
@@ -156,8 +148,8 @@ private static void attemptToAddPosixPermission(Path file, PosixFilePermission p
156148
*
157149
* @return The default version for Biome.
158150
*/
159-
private static String defaultVersion(BiomeFlavor flavor) {
160-
return flavor.defaultVersion();
151+
private static String defaultVersion() {
152+
return BiomeSettings.defaultVersion();
161153
}
162154

163155
/**
@@ -200,12 +192,12 @@ private static String resolveNameAgainstPath(String name) throws IOException, In
200192
* Checks the Biome config path. When the config path does not exist or when it
201193
* does not contain a file named {@code biome.json}, an error is thrown.
202194
*/
203-
private static void validateBiomeConfigPath(BiomeFlavor flavor, String configPath) {
195+
private static void validateBiomeConfigPath(String configPath) {
204196
if (configPath == null) {
205197
return;
206198
}
207199
var path = Paths.get(configPath);
208-
var config = path.resolve(flavor.configName());
200+
var config = path.resolve(BiomeSettings.configName());
209201
if (!Files.exists(path)) {
210202
throw new IllegalArgumentException("Biome config directory does not exist: " + path);
211203
}
@@ -227,14 +219,12 @@ private static void validateBiomeExecutable(String resolvedPathToExe) {
227219
/**
228220
* Creates a new Biome step with the configuration from the given builder.
229221
*
230-
* @param flavor Flavor of Biome to use.
231222
* @param version Version of the Biome executable to download.
232223
* @param pathToExe Path to the Biome executable to use.
233224
* @param downloadDir Directory where to place the downloaded executable.
234225
*/
235-
private BiomeStep(BiomeFlavor flavor, String version, String pathToExe, String downloadDir) {
236-
this.flavor = flavor;
237-
this.version = version != null && !version.isBlank() ? version : defaultVersion(flavor);
226+
private BiomeStep(String version, String pathToExe, String downloadDir) {
227+
this.version = version != null && !version.isBlank() ? version : defaultVersion();
238228
this.pathToExe = pathToExe;
239229
this.downloadDir = downloadDir;
240230
}
@@ -306,7 +296,7 @@ public BiomeStep withLanguage(String language) {
306296
private State createState() throws IOException, InterruptedException {
307297
var resolvedPathToExe = resolveExe();
308298
validateBiomeExecutable(resolvedPathToExe);
309-
validateBiomeConfigPath(flavor, configPath);
299+
validateBiomeConfigPath(configPath);
310300
logger.debug("Using Biome executable located at '{}'", resolvedPathToExe);
311301
var exeSignature = FileSignature.signAsList(Collections.singleton(new File(resolvedPathToExe)));
312302
makeExecutable(resolvedPathToExe);
@@ -337,7 +327,7 @@ private String resolveExe() throws IOException, InterruptedException {
337327
return pathToExe;
338328
}
339329
} else {
340-
var downloader = new BiomeExecutableDownloader(flavor, Paths.get(downloadDir));
330+
var downloader = new BiomeExecutableDownloader(Paths.get(downloadDir));
341331
var downloaded = downloader.ensureDownloaded(version).toString();
342332
makeExecutable(downloaded);
343333
return downloaded;

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/BiomeStepConfig.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
import javax.annotation.Nullable;
2525

26+
import com.diffplug.spotless.biome.BiomeSettings;
2627
import org.gradle.api.Project;
2728

2829
import com.diffplug.spotless.FormatterStep;
29-
import com.diffplug.spotless.biome.BiomeFlavor;
3030
import com.diffplug.spotless.biome.BiomeStep;
3131

3232
public abstract class BiomeStepConfig<Self extends BiomeStepConfig<Self>> {
@@ -48,12 +48,6 @@ public abstract class BiomeStepConfig<Self extends BiomeStepConfig<Self>> {
4848
@Nullable
4949
private Object downloadDir;
5050

51-
/**
52-
* The flavor of Biome to use. Will be removed when we stop support the
53-
* deprecated Rome project.
54-
*/
55-
private final BiomeFlavor flavor;
56-
5751
/**
5852
* Optional path to the Biome executable. Either a <code>version</code> or a
5953
* <code>pathToExe</code> should be specified. When not given, an attempt is
@@ -93,11 +87,9 @@ public abstract class BiomeStepConfig<Self extends BiomeStepConfig<Self>> {
9387
@Nullable
9488
private String version;
9589

96-
protected BiomeStepConfig(Project project, Consumer<FormatterStep> replaceStep, BiomeFlavor flavor,
97-
String version) {
90+
protected BiomeStepConfig(Project project, Consumer<FormatterStep> replaceStep, String version) {
9891
this.project = requireNonNull(project);
9992
this.replaceStep = requireNonNull(replaceStep);
100-
this.flavor = flavor;
10193
this.version = version;
10294
}
10395

@@ -224,10 +216,10 @@ private File findDataDir() {
224216
private BiomeStep newBuilder() {
225217
if (pathToExe != null) {
226218
var resolvedPathToExe = resolvePathToExe();
227-
return BiomeStep.withExePath(flavor, resolvedPathToExe);
219+
return BiomeStep.withExePath(resolvedPathToExe);
228220
} else {
229221
var downloadDir = resolveDownloadDir();
230-
return BiomeStep.withExeDownload(flavor, version, downloadDir);
222+
return BiomeStep.withExeDownload(version, downloadDir);
231223
}
232224
}
233225

@@ -260,7 +252,7 @@ private String resolveDownloadDir() {
260252
if (downloadDir != null) {
261253
return project.file(downloadDir).toString();
262254
} else {
263-
return findDataDir().toPath().resolve(flavor.shortName()).toString();
255+
return findDataDir().toPath().resolve(BiomeSettings.shortName()).toString();
264256
}
265257
}
266258
}

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/CssExtension.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
import javax.inject.Inject;
1919

20-
import com.diffplug.spotless.biome.BiomeFlavor;
21-
2220
/** Gradle step for formatting CSS files. */
2321
public class CssExtension extends FormatExtension {
2422
private static final String CSS_FILE_EXTENSION = "**/*.css";
@@ -73,7 +71,7 @@ public class BiomeCss extends BiomeStepConfig<BiomeCss> {
7371
* @param version Biome version to use.
7472
*/
7573
public BiomeCss(String version) {
76-
super(getProject(), CssExtension.this::replaceStep, BiomeFlavor.BIOME, version);
74+
super(getProject(), CssExtension.this::replaceStep, version);
7775
}
7876

7977
@Override

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import com.diffplug.spotless.OnMatch;
6060
import com.diffplug.spotless.Provisioner;
6161
import com.diffplug.spotless.SerializedFunction;
62-
import com.diffplug.spotless.biome.BiomeFlavor;
6362
import com.diffplug.spotless.cpp.ClangFormatStep;
6463
import com.diffplug.spotless.extra.EclipseBasedStepBuilder;
6564
import com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep;
@@ -825,13 +824,13 @@ public class BiomeGeneric extends BiomeStepConfig<BiomeGeneric> {
825824
* <code>null</code>.
826825
*/
827826
public BiomeGeneric(String version) {
828-
super(getProject(), FormatExtension.this::replaceStep, BiomeFlavor.BIOME, version);
827+
super(getProject(), FormatExtension.this::replaceStep, version);
829828
}
830829

831830
/**
832831
* Sets the language (syntax) of the input files to format. When
833832
* <code>null</code> or the empty string, the language is detected automatically
834-
* from the file name. Currently the following languages are supported by Biome:
833+
* from the file name. Currently, the following languages are supported by Biome:
835834
* <ul>
836835
* <li>js (JavaScript)</li>
837836
* <li>jsx (JavaScript + JSX)</li>

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavascriptExtension.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import com.diffplug.common.collect.ImmutableList;
3232
import com.diffplug.spotless.FormatterStep;
33-
import com.diffplug.spotless.biome.BiomeFlavor;
3433
import com.diffplug.spotless.npm.EslintConfig;
3534
import com.diffplug.spotless.npm.EslintFormatterStep;
3635
import com.diffplug.spotless.npm.NpmPathResolver;
@@ -169,7 +168,7 @@ public class BiomeJs extends BiomeStepConfig<BiomeJs> {
169168
* @param version Biome version to use.
170169
*/
171170
public BiomeJs(String version) {
172-
super(getProject(), JavascriptExtension.this::replaceStep, BiomeFlavor.BIOME, version);
171+
super(getProject(), JavascriptExtension.this::replaceStep, version);
173172
}
174173

175174
@Override

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JsonExtension.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import javax.inject.Inject;
2323

2424
import com.diffplug.spotless.FormatterStep;
25-
import com.diffplug.spotless.biome.BiomeFlavor;
2625
import com.diffplug.spotless.json.JacksonJsonConfig;
2726
import com.diffplug.spotless.json.JacksonJsonStep;
2827
import com.diffplug.spotless.json.JsonPatchStep;
@@ -192,7 +191,7 @@ public class BiomeJson extends BiomeStepConfig<BiomeJson> {
192191
* @param version Biome version to use.
193192
*/
194193
public BiomeJson(String version) {
195-
super(getProject(), JsonExtension.this::replaceStep, BiomeFlavor.BIOME, version);
194+
super(getProject(), JsonExtension.this::replaceStep, version);
196195
}
197196

198197
@Override

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/TypescriptExtension.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import com.diffplug.gradle.spotless.JavascriptExtension.EslintBaseConfig;
3232
import com.diffplug.spotless.FormatterStep;
33-
import com.diffplug.spotless.biome.BiomeFlavor;
3433
import com.diffplug.spotless.npm.EslintConfig;
3534
import com.diffplug.spotless.npm.EslintFormatterStep;
3635
import com.diffplug.spotless.npm.EslintTypescriptConfig;
@@ -254,7 +253,7 @@ public class BiomeTs extends BiomeStepConfig<BiomeTs> {
254253
* @param version Biome version to use.
255254
*/
256255
public BiomeTs(String version) {
257-
super(getProject(), TypescriptExtension.this::replaceStep, BiomeFlavor.BIOME, version);
256+
super(getProject(), TypescriptExtension.this::replaceStep, version);
258257
}
259258

260259
@Override

plugin-maven/src/main/java/com/diffplug/spotless/maven/css/BiomeCss.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
*/
1616
package com.diffplug.spotless.maven.css;
1717

18-
import com.diffplug.spotless.biome.BiomeFlavor;
1918
import com.diffplug.spotless.maven.generic.AbstractBiome;
2019

2120
/**
2221
* Biome formatter step for CSS.
2322
*/
2423
public class BiomeCss extends AbstractBiome {
2524
public BiomeCss() {
26-
super(BiomeFlavor.BIOME);
25+
super();
2726
}
2827

2928
@Override

0 commit comments

Comments
 (0)