diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml
index ec91171e..47f6e75a 100644
--- a/.github/workflows/pull-request.yaml
+++ b/.github/workflows/pull-request.yaml
@@ -39,7 +39,7 @@ jobs:
cache: 'maven'
- name: Validate pom formatting
- run: make lint-pom
+ run: make build-tools lint-pom
- name: Validate source code formatting
run: make lint-java
diff --git a/Makefile b/Makefile
index 8e97b095..d14dd925 100644
--- a/Makefile
+++ b/Makefile
@@ -12,16 +12,21 @@ REPACKAGE ?= true
clean:
./mvnw clean
+.PHONY: build-tools
+build-tools:
+ ./mvnw clean install -pl build-tools/
+
.PHONY: lint
-lint: lint-pom lint-java
+lint: build-tools
+ ./mvnw validate -Dqa -fae -ntp -T1C
.PHONY: lint-pom
lint-pom:
- ./mvnw sortpom:verify -Dsort.verifyFailOn=strict -Dsort.verifyFail=stop -ntp -T1C
+ ./mvnw validate -Dqa -fae -Dspotless.skip=true -Dcheckstyle.skip=true -ntp -T1C
.PHONY: lint-java
-lint-java:
- ./mvnw spotless:check -ntp -T1C
+lint-java: build-tools
+ ./mvnw validate -Dqa -fae -Dsortpom.skip=true -ntp -T1C
.PHONY: format
format: format-pom format-java
@@ -35,7 +40,7 @@ format-java:
./mvnw spotless:apply -ntp -T1C
.PHONY: install
-install:
+install: build-tools
./mvnw clean install -DskipTests -ntp -U -T1C
.PHONY: package
diff --git a/build-tools/README.md b/build-tools/README.md
new file mode 100644
index 00000000..bc8f0e62
--- /dev/null
+++ b/build-tools/README.md
@@ -0,0 +1,38 @@
+# GeoServer Cloud Build Tools
+
+This module contains centralized build configurations for the GeoServer Cloud project.
+
+## Checkstyle
+
+The build-tools module contains Checkstyle configuration that enforces consistent code style across the project. This approach follows the pattern used by many major Java projects including Apache Commons, Spring Framework, and Hibernate.
+
+### Key Features
+
+- **Centralized Configuration**: All code style rules are defined in a single place
+- **Enforced File Headers**: Ensures all Java files have the proper license header
+- **Import Control**: Forbids wildcard imports (e.g., `import java.util.*`) to improve code readability
+- **Consistent Code Style**: Enforces naming conventions, whitespace rules, and other code style guidelines
+
+### Configuration Files
+
+- `checkstyle.xml`: Main Checkstyle configuration file
+- `suppressions.xml`: Contains rules to suppress certain Checkstyle checks for specific files or patterns
+
+## Usage
+
+The build-tools module is referenced by the Maven Checkstyle plugin in the parent POM. The validation can be run with:
+
+```bash
+# Run checkstyle as part of the QA process
+mvn validate -Dqa
+
+# Run only checkstyle
+mvn validate -Dqa -Dspotless.skip=true -Dsortpom.skip=true
+```
+
+## Benefits
+
+1. **Consistency**: Ensures consistent code style across the entire project
+2. **Quality**: Helps catch common programming issues early
+3. **License Compliance**: Enforces proper license headers
+4. **Maintainability**: By prohibiting wildcard imports, it makes dependencies clearer
\ No newline at end of file
diff --git a/build-tools/pom.xml b/build-tools/pom.xml
new file mode 100644
index 00000000..29fa9c14
--- /dev/null
+++ b/build-tools/pom.xml
@@ -0,0 +1,19 @@
+
+
+ 4.0.0
+
+
+ org.geoserver.cloud
+ gs-cloud-bom
+ ${revision}
+
+
+ gs-cloud-build-tools
+ GeoServer Cloud Build Tools
+ Centralized build configurations for GeoServer Cloud
+
+
+
+ true
+
+
diff --git a/build-tools/src/main/resources/checkstyle/checkstyle.xml b/build-tools/src/main/resources/checkstyle/checkstyle.xml
new file mode 100644
index 00000000..ad962b1e
--- /dev/null
+++ b/build-tools/src/main/resources/checkstyle/checkstyle.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build-tools/src/main/resources/checkstyle/suppressions.xml b/build-tools/src/main/resources/checkstyle/suppressions.xml
new file mode 100644
index 00000000..395c3be9
--- /dev/null
+++ b/build-tools/src/main/resources/checkstyle/suppressions.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/develop/coding_standards.md b/docs/develop/coding_standards.md
new file mode 100644
index 00000000..221d176e
--- /dev/null
+++ b/docs/develop/coding_standards.md
@@ -0,0 +1,93 @@
+# Coding Standards and Style Guidelines
+
+GeoServer Cloud follows a set of coding standards to ensure code consistency and quality across the project. This document outlines the key standards and how they are enforced.
+
+## Contents
+{:.no_toc}
+
+* Will be replaced with the ToC, excluding the "Contents" header
+{:toc}
+
+## Introduction
+
+Code style consistency is enforced using automated tools during the build process. The project uses a build-tools module approach, similar to other major Java projects like Apache Commons, Spring Framework, and Hibernate, to centralize style configuration.
+
+## Checkstyle Configuration
+
+Checkstyle is used to enforce consistent code style and formatting standards. The configuration is located in the `build-tools` module.
+
+### Key Style Rules
+
+- **File Headers**: All Java files must include the proper license header
+- **Import Control**: Wildcard imports (e.g., `import java.util.*`) are forbidden to improve code readability
+- **Naming Conventions**: Standard Java naming conventions are enforced
+- **Whitespace**: Consistent tab and space usage is required
+- **Line Length**: Lines should not exceed 120 characters
+- **Coding Practices**: Various best practices are enforced, such as:
+ - Proper bracing
+ - Avoiding empty statements
+ - Implementing both `equals()` and `hashCode()`
+ - Simplifying boolean expressions
+
+### Configuration Files
+
+The Checkstyle configuration is stored in the following files:
+
+- `build-tools/src/main/resources/checkstyle/checkstyle.xml`: Main configuration
+- `build-tools/src/main/resources/checkstyle/suppressions.xml`: Rules for suppressing certain checks
+
+## Code Formatting
+
+In addition to Checkstyle, the project uses:
+
+- **Spotless**: For consistent Java code formatting using Palantir Java Format
+- **SortPOM**: For consistent XML formatting in pom.xml files
+
+## Running Style Checks
+
+Style checks are run as part of the build process. You can trigger them manually with:
+
+```bash
+# Run all checks
+mvn validate -Dqa -fae -ntp -T1C
+
+# Run only Java formatting checks
+mvn validate -Dqa -fae -Dsortpom.skip=true -ntp -T1C
+
+# Run only POM checks
+mvn validate -Dqa -fae -Dspotless.skip=true -Dcheckstyle.skip=true -ntp -T1C
+```
+
+## Fixing Style Issues
+
+To automatically fix style issues:
+
+```bash
+# Format all files
+make format
+
+# Format only Java files
+make format-java
+
+# Format only POM files
+make format-pom
+```
+
+## Integration with IDE
+
+Most common IDEs can be configured to follow these style guidelines:
+
+### IntelliJ IDEA
+
+- Install the Checkstyle-IDEA plugin
+- Configure it to use the project's Checkstyle configuration
+
+### Eclipse
+
+- Install the Checkstyle plugin
+- Configure it to use the project's Checkstyle configuration
+
+### VS Code
+
+- Install the Checkstyle for Java extension
+- Configure it to use the project's Checkstyle configuration
\ No newline at end of file
diff --git a/docs/develop/index.md b/docs/develop/index.md
index fdcd54ab..28292cf7 100644
--- a/docs/develop/index.md
+++ b/docs/develop/index.md
@@ -156,6 +156,10 @@ Each microservice is its own self-contained application, including only the GeoS
Check out the [build instructions](build_instructions.md) document.
+# Coding Standards
+
+GeoServer Cloud follows specific [coding standards and style guidelines](coding_standards.md) to ensure consistency across the project.
+
# Creating Extensions
Learn how to create [extensions for GeoServer Cloud](extensions/adding_extensions.md).
diff --git a/pom.xml b/pom.xml
index ccd25171..7f0895da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,15 +8,16 @@
pom
GeoServer Cloud
+ build-tools
src
2.27.0-SNAPSHOT
false
+ ${fmt.skip}
+ sort
+ ${fmt.skip}
apply
- ${fmt.skip}
- sort
- ${fmt.skip}
UTF-8
https://sonarcloud.io
@@ -355,35 +356,20 @@
jacoco-maven-plugin
0.8.11
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.1.0
+
-
- com.github.ekryd.sortpom
- sortpom-maven-plugin
-
- UTF-8
- true
- false
- false
- \n
- stop
- strict
- ${pom.fmt.skip}
-
-
-
-
- ${pom.fmt.action}
-
- verify
-
-
-
com.diffplug.spotless
spotless-maven-plugin
+ true
+ ${spotless.skip}
2.61.0
@@ -403,6 +389,29 @@
+
+ com.github.ekryd.sortpom
+ sortpom-maven-plugin
+ true
+
+ UTF-8
+ true
+ false
+ false
+ \n
+ stop
+ strict
+ ${sortpom.skip}
+
+
+
+
+ ${sortpom.action}
+
+ validate
+
+
+
org.codehaus.mojo
flatten-maven-plugin
@@ -430,19 +439,21 @@
-
- coverage
+ qa
false
- coverage
+ qa
-
- report-aggregate
-
+
+ check
+ verify
+ strict
+ stop
+
diff --git a/src/pom.xml b/src/pom.xml
index 79728799..2f5217f6 100644
--- a/src/pom.xml
+++ b/src/pom.xml
@@ -19,6 +19,7 @@
integration-tests
+ false
21
21
2021.0.9
@@ -950,6 +951,11 @@
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.6.0
+
org.apache.maven.plugins
maven-compiler-plugin
@@ -1501,5 +1507,53 @@
+
+ qa
+
+ false
+
+ qa
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ true
+
+ ${checkstyle.skip}
+ checkstyle/checkstyle.xml
+ checkstyle/suppressions.xml
+ true
+ true
+ false
+ true
+
+
+
+ org.geoserver.cloud
+ gs-cloud-build-tools
+ ${project.version}
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 10.12.5
+
+
+
+
+ validate
+
+ check
+
+ validate
+
+
+
+
+
+