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
平均合并
3 天 3 小时
30 天内合并 PR
14

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

diffplug/spotless 的其他 Issue

查看 diffplug/spotless 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。