This repository has been archived on 2026-10-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
barn/docs/development.md
Daniel SamsonandClaude Opus 4.5 3c09ea978d Add coding standards and quality enforcement tooling
- docs/coding-standards.md: Comprehensive Java coding standards
- CLAUDE.md: AI assistant instructions for the project
- .editorconfig: Editor configuration for consistent formatting
- pom.xml: Updated with quality plugins (Checkstyle, SpotBugs, PMD, JaCoCo)
- config/checkstyle/: Checkstyle configuration (Google Java Style based)
- config/spotbugs/: SpotBugs exclusions
- config/pmd/: PMD ruleset
- .githooks/pre-commit: Pre-commit hook for local quality checks
- .github/workflows/lint.yml: CI workflow for automated quality checks
- docs/development.md: Updated for Java/Maven toolchain

Quality enforcement:
- Checkstyle runs on validate phase
- SpotBugs and PMD run on verify phase
- JaCoCo enforces 80% line coverage, 70% branch coverage
- Pre-commit hook runs all checks before allowing commits
- CI runs all checks on push and PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:22:06 +00:00

6.9 KiB

Development Guide

This document covers local development setup and building Barn from source.


Prerequisites

Requirement Version Notes
JDK 21+ Required for building
Maven 3.9+ Build tool
GraalVM CE 21+ Required for native image builds (optional)
Git Any recent For version control

Installing JDK 21

macOS (Homebrew):

brew install openjdk@21

Linux (SDKMAN):

curl -s "https://get.sdkman.io" | bash
sdk install java 21-tem

Windows:

Download from Adoptium and add to PATH.

Installing Maven

macOS (Homebrew):

brew install maven

Linux:

sudo apt install maven  # Debian/Ubuntu
sudo dnf install maven  # Fedora

Windows:

Download from Apache Maven and add to PATH.

Installing GraalVM (Optional)

GraalVM is required for building native images.

macOS (Homebrew):

brew install --cask graalvm-jdk

Linux:

# Download from https://www.graalvm.org/downloads/
# Extract and set GRAALVM_HOME
export GRAALVM_HOME=/path/to/graalvm
export PATH=$GRAALVM_HOME/bin:$PATH

Windows:

Download from GraalVM Downloads and add to PATH.


Project Structure

barn/
  src/
    main/
      java/                # Application source code
      resources/           # Configuration and resource files
    test/
      java/                # Unit and integration tests
  config/
    checkstyle/            # Checkstyle configuration
    spotbugs/              # SpotBugs exclusions
    pmd/                   # PMD ruleset
  docs/                    # Documentation
  .githooks/               # Git hooks
  .github/workflows/       # CI/CD workflows
  pom.xml                  # Maven build configuration

Building

Build the JAR

mvn package

This compiles the source, runs tests, and produces a JAR in target/.

Skip Tests

mvn package -DskipTests

Build with All Quality Checks

mvn verify

Build without Quality Checks (Fast)

mvn package -Pfast

Clean Build

mvn clean package

Running Tests

Run All Tests

mvn test

Run Specific Test Class

mvn test -Dtest=JobManagerTest

Run Specific Test Method

mvn test -Dtest=JobManagerTest#createJob_shouldGenerateUniqueId

Run with Verbose Output

mvn test -X

Run Integration Tests

mvn verify

Generate Coverage Report

mvn test jacoco:report
# Open target/site/jacoco/index.html

Code Quality

Run Checkstyle

mvn checkstyle:check

Run SpotBugs

mvn compile spotbugs:check

# View in GUI
mvn compile spotbugs:gui

Run PMD

mvn compile pmd:check

Run All Quality Checks

mvn verify

Skip Quality Checks

mvn package -Pfast
# Or individually:
mvn package -Dcheckstyle.skip=true
mvn package -Dspotbugs.skip=true
mvn package -Dpmd.skip=true

Native Image Build

Building a native executable requires GraalVM:

# Ensure GraalVM is active
java -version  # Should show GraalVM

# Build native image
mvn package -Pnative

# The binary is output to target/barn

Running Locally

From JAR

java -jar target/barn-0.1.0-SNAPSHOT.jar --help

From Native Binary

./target/barn --help

Development Mode

Use the --offline flag to test commands without running the service:

java -jar target/barn-0.1.0-SNAPSHOT.jar run --offline echo hello

IDE Setup

  1. Open IntelliJ IDEA
  2. Select File > Open
  3. Navigate to the barn directory and open it
  4. IntelliJ will detect the Maven project and import it
  5. Wait for indexing to complete

Install Plugins:

  • CheckStyle-IDEA
  • SpotBugs

Import Code Style:

  1. Settings → Editor → Code Style → Java
  2. Click gear icon → Import Scheme → CheckStyle Configuration
  3. Select config/checkstyle/checkstyle.xml

Run Configuration:

  • Create Application configuration
  • Main class: com.samsonmedia.barn.Main
  • Program arguments: --help (or any command)

VS Code

  1. Install extensions: Java Extension Pack, Checkstyle for Java
  2. Open the barn folder
  3. The Java extension will detect the Maven project

Configure Checkstyle:

Settings → Checkstyle: Configuration → set to config/checkstyle/checkstyle.xml

Eclipse

  1. Import as Maven project
  2. Install Checkstyle plugin from Marketplace
  3. Configure to use config/checkstyle/checkstyle.xml

Git Hooks

Install the pre-commit hook to run checks before each commit:

git config core.hooksPath .githooks

The hook runs:

  • Checkstyle
  • Compilation check
  • SpotBugs
  • PMD

To bypass (use sparingly):

git commit --no-verify

Common Tasks

Format Code

IntelliJ IDEA: Code → Reformat Code (Ctrl+Alt+L / Cmd+Alt+L)

VS Code: Right-click → Format Document

Update Dependencies

mvn versions:display-dependency-updates
mvn versions:display-plugin-updates

Generate Project Reports

mvn site
# Open target/site/index.html

Troubleshooting

Compilation Fails with Lint Errors

The project uses -Werror to treat warnings as errors. Fix all warnings:

# See detailed warnings
mvn compile -X

Tests Fail on Windows

Ensure line endings are consistent:

git config core.autocrlf input

Checkstyle Violations

View details:

mvn checkstyle:checkstyle
# Open target/site/checkstyle.html

SpotBugs Issues

View in GUI:

mvn compile spotbugs:gui

Out of Memory During Build

Increase Maven heap:

export MAVEN_OPTS="-Xmx2g"
mvn package

Native Image Build Fails

Common causes:

  1. Reflection configuration missing: Add to src/main/resources/META-INF/native-image/reflect-config.json
  2. Resource not included: Add to resource-config.json
  3. Insufficient memory: Increase heap with -J-Xmx8g

Environment Variables

Variable Description
JAVA_HOME Path to JDK installation
GRAALVM_HOME Path to GraalVM installation
MAVEN_OPTS JVM options for Maven
BARN_LOG_LEVEL Override log level during development

Useful Maven Commands

# Clean everything
mvn clean

# Compile only
mvn compile

# Run tests
mvn test

# Package JAR
mvn package

# Install to local repo
mvn install

# Full verification
mvn verify

# Generate site/reports
mvn site

# Dependency tree
mvn dependency:tree

# Effective POM
mvn help:effective-pom

Next Steps