google / google/google-java-format
How to run google-java-format from Bazel?
- 主要語言
- Java
- 星號
- 6.2k
- 分支
- 937
- 平均合併
- 6 分鐘
- 30 天內合併 PR
- 3
描述
I would like to run `google-java-format` in an (open source) project which uses Bazel as build system.
I currently have it set up using https://github.com/dustinsand/pre-commit-jvm (with https://pre-commit.com) but it strikes me as "odd" having to install https://get-coursier.io and relying on `dustinsand/pre-commit-jvm` when it should be possible to "just" have a (Maven) dependency on this in Bazel and "run it" - I'm just not entirely sure HOW one would be run a Java based tool like this one from Bazel...
... I have briefly explored something like what [this post on `bazel-discuss`](https://groups.google.com/g/bazel-discuss/c/eQTAycAqi1g/m/AJIv7uDqBgAJ) may have been after, and started to write my own `GoogleJavaFormatTest` using this project's API, but it doesn't seem to be intended to used like that (`UsageException` is package local only, even though `Main#format(String... args) throws UsageException`) - and integrated this as a `b test //...` is perhaps that's the wrong way to go about this anyway?
How would one best run google-java-format from Bazel? You would want it "run whenever any *.java changed", and one would want it to fail the build if the formatting was wrong - but re-write (correct) the source files. Is this possible with Bazel? How does one even "run a main() method from a dependency" for something like this?
@cushon perhaps you have some wise guidance?
貢獻指南
研究方向
先從 issue 中的 Bazel 和 pre-commit 脈絡開始,接著檢查 google-java-format 的 Main#format(String... args) 以及提議的 GoogleJavaFormatTest。完成條件是提供一個有文件記錄且可重現的 Bazel 工作流程,對已變更的 Java 檔案執行 formatter,並定義預期的 build 行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- build-system
- Issue 類型
- 文件
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100