Skip to content

Commit be05d1e

Browse files
committed
ci fix
1 parent 99a98c3 commit be05d1e

5 files changed

Lines changed: 67 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) together wi
111111

112112
- Formatter: `clang-format` only
113113
- Version: pinned as `clang.format.version` in the root `pom.xml` (currently `17.0.6`, aligned with Apache TsFile); CI installs LLVM/clang-format so the default `clang-format` on the runner matches that version
114-
- Entrypoint: Maven Spotless
114+
- Entrypoint: Maven Spotless; the `clangFormat` configuration is attached under the `spotless-cpp` profile in the C++ modules and activates only on **JDK 11+**, so run `spotless:check` / `spotless:apply` for C++ with JDK 11 or newer (CI does). JDK 8 builds elsewhere in the reactor do not load that Spotless fragment.
115115

116116
Check only:
117117

example/client-cpp-example/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,36 @@
162162
</plugin>
163163
</plugins>
164164
</build>
165+
<profiles>
166+
<profile>
167+
<id>spotless-cpp</id>
168+
<activation>
169+
<jdk>[11,)</jdk>
170+
</activation>
171+
<build>
172+
<plugins>
173+
<plugin>
174+
<groupId>com.diffplug.spotless</groupId>
175+
<artifactId>spotless-maven-plugin</artifactId>
176+
<version>2.44.5</version>
177+
<configuration>
178+
<cpp>
179+
<includes>
180+
<include>src/**/*.h</include>
181+
<include>src/**/*.hpp</include>
182+
<include>src/**/*.c</include>
183+
<include>src/**/*.cc</include>
184+
<include>src/**/*.cpp</include>
185+
</includes>
186+
<clangFormat>
187+
<version>${clang.format.version}</version>
188+
<style>file</style>
189+
</clangFormat>
190+
</cpp>
191+
</configuration>
192+
</plugin>
193+
</plugins>
194+
</build>
195+
</profile>
196+
</profiles>
165197
</project>

iotdb-client/client-cpp/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ We use `clang-format` as the only formatter for C++ code and trigger it through
104104

105105
The version is pinned in the root `pom.xml` as property `clang.format.version` (same approach as Apache TsFile). Use **clang-format 17.0.6** locally so Spotless agrees with CI.
106106

107+
**JDK for Maven:** the C++ `clangFormat` step is registered only when running Maven on **JDK 11 or newer** (see the `spotless-cpp` profile in this module and in `client-cpp-example`). The repository root still supports JDK 8 for Java builds, but `spotless:check` / `spotless:apply` for C++ will not apply the clang-format rules if you use JDK 8.
108+
107109
### Install clang-format 17.0.6
108110

109111
- Linux (Ubuntu): On **24.04+**, `sudo apt-get install -y clang-format-17`. On **22.04**, that package is not in the default archive; install LLVM 17 via [apt.llvm.org](https://apt.llvm.org/) (e.g. download `llvm.sh` and run `sudo ./llvm.sh 17`, as CI does). Then point the default `clang-format` at 17.x (Spotless invokes `clang-format` on `PATH`; some releases default to another major version):

iotdb-client/client-cpp/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,5 +443,36 @@
443443
</plugins>
444444
</build>
445445
</profile>
446+
<!-- Spotless &lt;clangFormat&gt; needs Spotless 2.44+; root POM downgrades to 2.27.1 on JDK8 and cannot parse cpp config. Only register C++ rules when JDK 11+. -->
447+
<profile>
448+
<id>spotless-cpp</id>
449+
<activation>
450+
<jdk>[11,)</jdk>
451+
</activation>
452+
<build>
453+
<plugins>
454+
<plugin>
455+
<groupId>com.diffplug.spotless</groupId>
456+
<artifactId>spotless-maven-plugin</artifactId>
457+
<version>2.44.5</version>
458+
<configuration>
459+
<cpp>
460+
<includes>
461+
<include>src/**/*.h</include>
462+
<include>src/**/*.hpp</include>
463+
<include>src/**/*.c</include>
464+
<include>src/**/*.cc</include>
465+
<include>src/**/*.cpp</include>
466+
</includes>
467+
<clangFormat>
468+
<version>${clang.format.version}</version>
469+
<style>file</style>
470+
</clangFormat>
471+
</cpp>
472+
</configuration>
473+
</plugin>
474+
</plugins>
475+
</build>
476+
</profile>
446477
</profiles>
447478
</project>

pom.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -837,19 +837,7 @@
837837
</importOrder>
838838
<removeUnusedImports/>
839839
</java>
840-
<cpp>
841-
<includes>
842-
<include>src/**/*.h</include>
843-
<include>src/**/*.hpp</include>
844-
<include>src/**/*.c</include>
845-
<include>src/**/*.cc</include>
846-
<include>src/**/*.cpp</include>
847-
</includes>
848-
<clangFormat>
849-
<version>${clang.format.version}</version>
850-
<style>file</style>
851-
</clangFormat>
852-
</cpp>
840+
<!-- C++ clang-format requires Spotless 2.44+ (see client-cpp / client-cpp-example poms). Not here: JDK8 CI uses Spotless 2.27.1 which cannot parse &lt;clangFormat&gt;. -->
853841
<lineEndings>UNIX</lineEndings>
854842
</configuration>
855843
<executions>

0 commit comments

Comments
 (0)