Expose `maxLineLength` on the `googleJavaFormat` step (configurable upstream since gjf 1.37.0)
维护者通常 1 天内回复
评估
- 难度
- 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, anduseTabs/indentationMultiplierbecame programmatically settable on the same builder — potential follow-ups, not part of this request.
- 主要语言
- Java
- 星标
- 5.7k
- 派生
- 563
- 平均合并
- 3 天 3 小时
- 30 天内合并 PR
- 14
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
diffplug/spotless 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 70/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 43/100
diffplug/spotless#3147 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 28/100
维护者通常 1 天内回复
查看 diffplug/spotless 的全部 Issue
相似的 Issue
-
breaking change bug needs human review not ready priority medium size S
难度 2/5 1-3 小时 新手友好度 76/100
martin-francois/symphony-trello#1193 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Mend: dependency security vulnerability
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复