Skip to content

Commit

Permalink
Switch to Biome for JSON formatting (#7967)
Browse files Browse the repository at this point in the history
Replaces the previous Prettier step which required a separate
installation of npm to work at all. Biome no longer requires any extra
dependencies as Spotless will simply grab a static binary to use from
within `mavenLocal`.

~~Note that the `biome()` step also adds the `mavenLocal()` repository
definition to the buildscript, which causes the project build to fail
when using `RepositoriesMode.FAIL_ON_PROJECT_REPOS` in the settings
file.~~

---------

Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
  • Loading branch information
62832 and shartte committed Jun 26, 2024
1 parent 05f15aa commit b6cdde9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ configurations {
}

import appengbuild.*
import com.diffplug.gradle.spotless.JsonExtension

dependencies {
// To be copied into the jar file
Expand Down Expand Up @@ -411,14 +412,23 @@ spotless {
if (it.contains('*;\n')) {
throw new Error('No wildcard imports allowed')
}

it
}
bumpThisNumberIfACustomStepChanges(1)
}

format 'json', {
json {
target 'src/*/resources/**/*.json'
targetExclude 'src/generated/resources/**'
prettier().config(['parser': 'json'])
var biomeConfig = it.new JsonExtension.BiomeJson(null)
try {
biomeConfig.downloadDir(new File(rootDir, ".gradle/biome").absolutePath)
} catch (Exception ignored) {
}
addStep(biomeConfig.createStep())
indentWithSpaces(2)
endWithNewline()
}
}

Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
rulesMode = RulesMode.FAIL_ON_PROJECT_RULES
repositories {
mavenLocal()
maven {
url "https://maven.shedaniel.me/"
content {
Expand Down

0 comments on commit b6cdde9

Please sign in to comment.