Commit f850f56
authored
Fix spotless:apply failure on modern JDKs (#777)
## Summary
- Pin `google-java-format` to **1.22.0** in the root `pom.xml` so `mvn
spotless:apply` stops crashing on modern JDKs
(the code generator runs on JDK 25, where spotless-maven-plugin 2.30.0's
bundled GJF 1.15.0 throws
`NoSuchMethodError` against the renamed
`com.sun.tools.javac.util.Log$DeferredDiagnosticHandler.getDiagnostics()`
signature). 1.22.0 is the last GJF release that still supports JRE 11,
keeping local dev and the JDK 11 `fmt` CI job
working.
- Add `scripts/mvn-spotless-apply.sh`, a drop-in wrapper that exports
`MAVEN_OPTS` with the
`--add-exports=jdk.compiler/com.sun.tools.javac.*=ALL-UNNAMED` flags
required by GJF on JDK 16+. It detects the JDK
major version and only sets the flags when needed, so older JDKs
(including the JDK 8 CI matrix rows) are untouched.
`.codegen.json`'s `post_generate` now invokes the wrapper instead of
`mvn spotless:apply` directly, mirroring the
existing `bash scripts/cleanup-services.sh` pattern.
- One-time reformat of 6 files (16 blank lines inserted, 0 deletions) to
satisfy GJF 1.22.0's stricter rules around
blank lines between documented fields. No semantic changes.
### Why a wrapper script and not `.mvn/jvm.config`?
`.mvn/jvm.config` applies to every Maven invocation, and this repo's CI
matrix runs `mvn test` / release jobs under
JDK 8, where `--add-exports` is an unrecognized arg and Maven would fail
to start. Scoping the flags to the one
command that actually needs them (`spotless:apply`) avoids that blast
radius.
### Impact on CI
- `fmt` (JDK 11 → `spotless:check`): GJF 1.22.0 loads fine on JRE 11.
- `unit-tests` matrix (JDK 8/11/17/20 → `mvn test`): unaffected,
spotless plugin has no `<execution>` binding so it
never runs during tests.
- `release-build-check` / `package` (JDK 8): unaffected, same reason.
- Compiled bytecode target remains Java 8; GJF only reformats source
whitespace.
## Test plan
- [x] `mvn spotless:check` passes on local JDK 11 after the reformat
- [x] `mvn spotless:apply` on clean HEAD (after pom bump) produces the
expected 6-file reformat only; subsequent runs
are no-ops (idempotent)
- [x] `bash scripts/mvn-spotless-apply.sh` on JDK 11 correctly skips the
`MAVEN_OPTS` export (`JDK < 16`) and
delegates to `mvn spotless:apply` with `BUILD SUCCESS`
- [x] CI green across all matrix rows (JDK 8/11/17/20 unit-tests, JDK 11
fmt, JDK 8 release-build-check)
NO_CHANGELOG=true1 parent 547b204 commit f850f56
9 files changed
Lines changed: 52 additions & 2 deletions
File tree
- databricks-sdk-java/src
- main/java/com/databricks/sdk
- core
- http
- oauth
- test/java/com/databricks/sdk/service/gentesting/unittests
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments