Build integration for Java Backend Coding Technology - automated formatting and linting in your Maven build.
The JBCT Maven Plugin provides:
| Goal | Description | Default Phase |
|---|---|---|
jbct:format |
Format source files in-place | process-sources |
jbct:format-check |
Check formatting (fail if issues) | verify |
jbct:lint |
Run lint rules | verify |
jbct:check |
Combined format-check + lint | verify |
jbct:collect-slice-deps |
Collect slice API dependencies | generate-sources |
jbct:verify-slice |
Validate slice configuration | verify |
Add to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.pragmatica-lite</groupId>
<artifactId>jbct-maven-plugin</artifactId>
<version>0.4.6</version>
</plugin>
</plugins>
</build>
Format Java source files in-place to JBCT style.
mvn jbct:format
Behavior:
src/main/javaExample output:
[INFO] Formatting src/main/java/com/example/Email.java [INFO] Formatting src/main/java/com/example/Password.java [INFO] Formatted 2 files
Check formatting without modifying files. Fails if any file needs formatting.
mvn jbct:format-check
Behavior:
src/main/javaExample output (success):
[INFO] All 47 files are properly formatted
Example output (failure):
[ERROR] 3 files need formatting: [ERROR] src/main/java/com/example/Email.java [ERROR] src/main/java/com/example/Password.java [ERROR] src/main/java/com/example/User.java
Run JBCT lint rules (37 rules) against source files.
mvn jbct:lint
Behavior:
Example output:
[INFO] Linting src/main/java...
[ERROR] src/main/java/com/example/User.java:15
JBCT-RET-04: Use Unit instead of Void
[WARNING] src/main/java/com/example/Email.java:23
JBCT-STY-01: Prefer fluent failure: cause.result() not Result.failure(cause)
[INFO] 1 error, 1 warning
Combined format-check and lint (recommended for CI).
mvn jbct:check
Behavior:
Example output:
[INFO] --- jbct:check --- [INFO] Checking formatting... [INFO] All 47 files are properly formatted [INFO] Running lint rules... [INFO] All checks passed
Collect API dependencies for Aether slice projects.
mvn jbct:collect-slice-deps
Behavior:
Validate Aether slice project configuration.
mvn jbct:verify-slice
Behavior:
pom.xml for required propertiesBind the check goal to automatically run during mvn verify:
<plugin>
<groupId>org.pragmatica-lite</groupId>
<artifactId>jbct-maven-plugin</artifactId>
<version>0.4.6</version>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Now mvn verify (and mvn install, mvn deploy) automatically runs JBCT checks.
Auto-format during compilation:
<executions>
<execution>
<id>format</id>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
Combine formatting and checking:
<executions>
<execution>
<id>format</id>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<plugin>
<groupId>org.pragmatica-lite</groupId>
<artifactId>jbct-maven-plugin</artifactId>
<version>0.4.6</version>
<configuration>
<!-- Skip JBCT processing -->
<skip>false</skip>
<!-- Include test sources -->
<includeTests>false</includeTests>
</configuration>
</plugin>
| Option | Type | Default | Description |
|---|---|---|---|
skip |
boolean | false |
Skip JBCT processing entirely |
includeTests |
boolean | false |
Include test sources in processing |
# Skip JBCT for single run mvn verify -Djbct.skip=true
The Maven plugin reads configuration from jbct.toml in your project root. All formatting and linting settings are shared between CLI and Maven plugin.
Create jbct.toml:
[format] maxLineLength = 120 indentSize = 4 alignChainedCalls = true [lint] failOnWarning = false businessPackages = ["**.usecase.**", "**.domain.**"] slicePackages = ["**.usecase.**"] # Required for JBCT-SLICE-01 [lint.rules] JBCT-RET-01 = "error" JBCT-STY-01 = "warning" JBCT-LOG-01 = "off"
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: maven
- name: Build and Verify
run: mvn verify -B
With the plugin bound to the verify phase, mvn verify automatically runs all JBCT checks.
build:
image: maven:3.9-eclipse-temurin-25
script:
- mvn verify -B
cache:
paths:
- .m2/repository
pipeline {
agent {
docker { image 'maven:3.9-eclipse-temurin-25' }
}
stages {
stage('Build') {
steps {
sh 'mvn verify -B'
}
}
}
}
# Format code before commit mvn jbct:format # Check everything mvn verify
Create .git/hooks/pre-commit:
#!/bin/bash
mvn jbct:format-check -q
if [ $? -ne 0 ]; then
echo "JBCT format check failed. Run 'mvn jbct:format' to fix."
exit 1
fi
Configure your IDE to run mvn jbct:format on save or use the JBCT CLI directly:
jbct format src/main/java
The Maven plugin uses the same 37 lint rules as the CLI. See CLI Tooling for the complete reference.
| Category | Rules | Description |
|---|---|---|
| Return Kinds | 5 | T, Option, Result, Promise usage |
| Value Objects | 2 | Factory patterns, construction |
| Exceptions | 2 | No business exceptions |
| Naming | 2 | Factory methods, Valid prefix |
| Lambda | 4 | Complexity, braces, ternary |
| Patterns | 3 | Iteration, mixing, chain length |
| Style | 6 | Fluent failures, references, imports |
| Logging | 2 | Conditional logging, ownership |
| Architecture | 1 | I/O in domain |
| Static Imports | 1 | Pragmatica factories |
| Utilities | 2 | Parsing, verification |
| Nesting | 1 | Nested monadic ops |
| Zones | 3 | Verb consistency |
| Acronyms | 1 | PascalCase |
| Sealed Types | 1 | Error interfaces |
| Slice | 1 | API dependencies |
Use standard Java @SuppressWarnings annotation to suppress JBCT rules:
// Suppress single rule @SuppressWarnings("JBCT-RET-01") public void legacyMethod() { // This method won't trigger JBCT-RET-01 } // Suppress multiple rules @SuppressWarnings({"JBCT-RET-01", "JBCT-LAM-02"}) public void anotherMethod() { // Won't trigger either rule } // Suppress all JBCT rules @SuppressWarnings("all") public class LegacyAdapter { // No JBCT rules checked in this class }
Scope: Suppression applies to the annotated element and its children:
Ensure you have access to Maven Central:
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
JBCT requires Java 25+:
<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
</properties>
If format-check fails but format shows no changes, ensure:
jbct.toml configurationIf you find this useful, consider sponsoring.
Apache 2.0