Skip to content

Commit 66effa0

Browse files
authored
Sort Gradle dependencies (#49)
1 parent cc338d9 commit 66effa0

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ wget https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/
9292
chmod +x clang-format
9393
wget https://github.com/google/google-java-format/releases/download/v1.24.0/google-java-format-1.24.0-all-deps.jar -O google-java-format
9494
wget https://search.maven.org/remotecontent?filepath=com/facebook/ktfmt/0.53/ktfmt-0.53-jar-with-dependencies.jar -O ktfmt
95+
wget https://repo1.maven.org/maven2/com/squareup/sort-gradle-dependencies-app/0.14/sort-gradle-dependencies-app-0.14-all.jar -O gradle-dependencies-sorter
9596
wget https://github.com/mvdan/sh/releases/download/v3.10.0/shfmt_v3.10.0_linux_amd64 -O shfmt
9697
chmod +x shfmt
9798
wget https://github.com/tamasfe/taplo/releases/download/0.9.3/taplo-linux-x86_64.gz -O taplo.gz

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This repo currently contains a single [pre-commit](https://pre-commit.com/) hook
1010
- [isort](https://github.com/PyCQA/isort) v5.13.2 for Python 2
1111
- [google-java-format](https://github.com/google/google-java-format) v1.24.0 for Java
1212
- [ktfmt](https://github.com/facebookincubator/ktfmt) v0.53 for Kotlin
13+
- [gradle-dependencies-sorter](https://github.com/square/gradle-dependencies-sorter) v0.14 for Gradle
1314
- [gofmt](https://pkg.go.dev/cmd/gofmt) v1.23.3 for Go
1415
- [scalafmt](https://scalameta.org/scalafmt/) v3.8.3 for Scala
1516
- [shfmt](https://github.com/mvdan/sh) v3.10.0 for Shell

entry.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const enum HookName {
8383
EsLint = "ESLint",
8484
Gofmt = "gofmt",
8585
GoogleJavaFormat = "google-java-format",
86+
GradleDependenciesSorter = "gradle-dependencies-sorter",
8687
Isort = "isort",
8788
Ktfmt = "ktfmt",
8889
PrettierJs = "Prettier (JS)",
@@ -220,6 +221,12 @@ const HOOKS: Record<HookName, LockableHook> = {
220221
include: /\.java$/,
221222
runAfter: [HookName.Sed],
222223
}),
224+
[HookName.GradleDependenciesSorter]: createLockableHook({
225+
action: sources =>
226+
run("java", "-jar", "/gradle-dependencies-sorter", ...sources),
227+
include: /build\.gradle(\.kts)?$/,
228+
runAfter: [HookName.Sed],
229+
}),
223230
[HookName.Isort]: createLockableHook({
224231
// isort's automatic config file detection is broken
225232
// https://github.com/PyCQA/isort/issues/1907

test/after/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies {
2+
implementation(libs.androidx.core.core)
3+
implementation(libs.commons.io)
4+
implementation(libs.google.material)
5+
}

test/before/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies {
2+
implementation(libs.google.material)
3+
implementation(libs.commons.io)
4+
implementation(libs.androidx.core.core)
5+
}

0 commit comments

Comments
 (0)