Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Expose `maxLineLength` on the `googleJavaFormat` step (configurable upstream since gjf 1.37.0)

未關閉
#3,151 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@xzxiaoshan 已經在處理了。

開始於 2026年10月23日。

  • #3152 來自 @xzxiaoshan —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
28/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
groovy, java

研究方向

Start with the googleJavaFormat step implementation and its existing style, reflowLongStrings, and formatJavadoc option plumbing. Locate the Gradle and Maven configuration entry points, then run their googleJavaFormat step tests. Done means maxLineLength is exposed for google-java-format 1.37.0+, is rejected or unavailable for older versions, and is covered by both build-tool configurations.

由索引模型根據 Issue 內容生成。

描述

Summary

The googleJavaFormat step currently has no way to configure the column limit, and historically there was no way to add one: upstream hard-coded 100 columns in Formatter.MAX_LINE_LENGTH, a public static final constant that got inlined at compile time — which is why #1563 was closed back in 2023 as impossible to implement.

That upstream blocker is now gone. google-java-format v1.37.0 (released 2026-10-01) added an official --max-line-length flag, resolving google/google-java-format#425 (open since Dec 2019). The gjf maintainers describe it as an orthogonal option — it moves the column limit without changing any other layout decisions — so exposing it doesn't conflict with the "opinionated, minimal configuration" philosophy.

What the new API looks like

The hard-coded constant was removed; the limit now flows through the options object. JavaFormatterOptions.Style is now a record with a public builder that Spotless can call directly (the step already builds a JavaFormatterOptions for the existing style / reflowLongStrings / formatJavadoc settings):

JavaFormatterOptions.Style.builder()
    .aosp()              // or .google()
    .maxLineLength(120)
    .build();

(landed in 6b86849)

Requested

Expose the option on the step, gated on gjf 1.37.0+:

Gradle:

googleJavaFormat {
    maxLineLength(120)
}

Maven:

<googleJavaFormat>
    <version>1.37.0</version>
    <maxLineLength>120</maxLineLength>
</googleJavaFormat>
Considerations
  • gjf 1.29+ requires JDK 21+ to run. Spotless already applies JVM-tiered defaults for gjf (1.28.0 on JVM 17, newer on 21+), so this option would effectively require the JVM-21 tier with an explicit gjf version of 1.37.0 or newer.
  • The default-version bump to 1.37.0 is currently pending in #3130.
  • 1.37.0 also added --style=google|aosp, and useTabs / indentationMultiplier became programmatically settable on the same builder — potential follow-ups, not part of this request.
主要語言
Java
星號
5.7k
分支
563
平均合併
2 天 11 小時
30 天內合併 PR
13

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

diffplug/spotless 的其他 Issue

查看 diffplug/spotless 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。