You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sourcelume.apache.org by an...@apache.org on 2026/10/03 13:24:59 UTC

(sourcelume-registry) 03/07: Configure Spotless and Checkstyle

This is an automated email from the ASF dual-hosted git repository.

ANierbeck pushed a commit to branch ci
in repository https://gitbox.apache.org/repos/asf/sourcelume-registry.git

commit 164e808d53408b1200cf300ac83d088721cfc9a0
Author: anierbeck <ac...@codecentric.de>
AuthorDate: Sat Oct 3 14:17:33 2026 +0200

    Configure Spotless and Checkstyle
    
    Same tools and rules as sourcelume-spec: palantir-java-format,
    import order, unused-import removal, the ASF license header from
    dev/license-header.txt, and sortPom for the poms; checkstyle bans
    JUnit 3/4 imports. The check goals are deliberately not bound yet -
    the one-off reformat lands in its own commit first so it stays
    reviewable and can be listed in .git-blame-ignore-revs.
    
    Apache-ai: Yes
    Generated-by: pi (claude-bridge/claude-opus-5-5)
    Reviewed-by: anierbeck
---
 dev/checkstyle.xml     | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 dev/license-header.txt | 16 +++++++++++++++
 pom.xml                | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 119 insertions(+)

diff --git a/dev/checkstyle.xml b/dev/checkstyle.xml
new file mode 100644
index 0000000..08789c8
--- /dev/null
+++ b/dev/checkstyle.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+      Licensed to the Apache Software Foundation (ASF) under one or more
+      contributor license agreements.  See the NOTICE file distributed with
+      this work for additional information regarding copyright ownership.
+      The ASF licenses this file to You under the Apache License, Version 2.0
+      (the "License"); you may not use this file except in compliance with
+      the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+      Unless required by applicable law or agreed to in writing, software
+      distributed under the License is distributed on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+      See the License for the specific language governing permissions and
+      limitations under the License.
+  -->
+<!DOCTYPE module PUBLIC
+    "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+    "https://checkstyle.org/dtds/configuration_1_3.dtd">
+
+<!--
+  Minimal Checkstyle configuration. Formatting is owned by Spotless
+  (palantir-java-format); this file only enforces structural rules that a
+  formatter cannot express. Add rules deliberately and sparingly.
+-->
+<module name="Checker">
+  <property name="charset" value="UTF-8"/>
+  <property name="severity" value="error"/>
+
+  <module name="TreeWalker">
+    <!--
+      Tests must use JUnit 5 (Jupiter). Reject JUnit 3 (junit.framework)
+      and JUnit 4 (org.junit.*) imports while allowing org.junit.jupiter
+      and org.junit.platform.
+    -->
+    <module name="IllegalImport">
+      <property name="regexp" value="true"/>
+      <!--
+        Checkstyle appends "\..*" to each package pattern, so entries must
+        not end with a trailing dot.
+      -->
+      <property name="illegalPkgs"
+                value="^junit, ^org\.junit(?!\.(jupiter|platform)\.)"/>
+      <message key="import.illegal"
+               value="JUnit 3/4 is banned; use JUnit 5 (org.junit.jupiter) instead."/>
+    </module>
+  </module>
+</module>
diff --git a/dev/license-header.txt b/dev/license-header.txt
new file mode 100644
index 0000000..3e7c6c2
--- /dev/null
+++ b/dev/license-header.txt
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
diff --git a/pom.xml b/pom.xml
index f848e3e..effafa0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,11 @@
         <slf4j.version>2.0.16</slf4j.version>
         <junit.version>5.11.4</junit.version>
         <sourcelume-spec.version>0.0.1-SNAPSHOT</sourcelume-spec.version>
+
+        <!-- Plugin versions (formatting and style, same tools as sourcelume-spec) -->
+        <spotless-maven-plugin.version>2.44.5</spotless-maven-plugin.version>
+        <maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
+        <checkstyle.version>10.26.1</checkstyle.version>
     </properties>
 
     <dependencyManagement>
@@ -172,6 +177,54 @@
                     </execution>
                 </executions>
             </plugin>
+
+            <!--
+                Spotless owns formatting: palantir-java-format for Java,
+                license headers from dev/license-header.txt, and sortPom for
+                the poms. Checkstyle adds structural rules Spotless cannot
+                express (dev/checkstyle.xml: JUnit 3/4 imports are banned).
+                Both mirror sourcelume-spec so both repos share one style.
+                The check goals are bound in a follow-up commit once the
+                one-off reformat has landed; `mvn spotless:apply` fixes drift.
+            -->
+            <plugin>
+                <groupId>com.diffplug.spotless</groupId>
+                <artifactId>spotless-maven-plugin</artifactId>
+                <version>${spotless-maven-plugin.version}</version>
+                <configuration>
+                    <java>
+                        <palantirJavaFormat/>
+                        <importOrder/>
+                        <removeUnusedImports/>
+                        <licenseHeader>
+                            <file>${maven.multiModuleProjectDirectory}/dev/license-header.txt</file>
+                        </licenseHeader>
+                    </java>
+                    <pom>
+                        <sortPom>
+                            <expandEmptyElements>false</expandEmptyElements>
+                        </sortPom>
+                    </pom>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>${maven-checkstyle-plugin.version}</version>
+                <configuration>
+                    <configLocation>${maven.multiModuleProjectDirectory}/dev/checkstyle.xml</configLocation>
+                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
+                    <consoleOutput>true</consoleOutput>
+                    <failOnViolation>true</failOnViolation>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>com.puppycrawl.tools</groupId>
+                        <artifactId>checkstyle</artifactId>
+                        <version>${checkstyle.version}</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
         </plugins>
     </build>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@sourcelume.apache.org
For additional commands, e-mail: commits-help@sourcelume.apache.org