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
T
Daniel SamsonandClaude Opus 4.5 cf750b6eb5 Add comprehensive project documentation
- docs/config.md: Configuration options, retry behavior, cleanup policies
- docs/development.md: Local dev setup, building from source
- docs/releasing.md: Version management, release process, AUR/Homebrew automation
- docs/ci-cd.md: GitHub Actions workflows for build, release, AUR, Homebrew
- docs/distribution.md: Package manager setup (WinGet, apt, AUR, Homebrew)
- docs/auto-update.md: Built-in barn update command
- docs/testing-automated.md: Test suite, running tests, CI integration
- docs/testing-manual.md: Step-by-step manual test procedures
- docs/jobs.md: Added retry-related state files
- README.md: Updated documentation links

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

4.2 KiB

Development Guide

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


Prerequisites

Requirement Version Notes
JDK 21+ Required for building
GraalVM CE 21+ Required for native image builds
Gradle 8.x Wrapper included in project
Git Any recent For version control

Installing GraalVM

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/
      kotlin/           # Application source code
      resources/        # Configuration and resource files
    test/
      kotlin/           # Unit and integration tests
  build.gradle.kts      # Build configuration
  gradle.properties     # Version and build properties
  settings.gradle.kts   # Project settings
  docs/                 # Documentation

Building

Build the JAR

./gradlew build

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

Run Tests

# Run all tests
./gradlew test

# Run specific test class
./gradlew test --tests "com.samsonmedia.barn.JobManagerTest"

# Run with verbose output
./gradlew test --info

Build Native Image

Building a native executable requires GraalVM with Native Image support:

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

# Build native image
./gradlew nativeCompile

The native binary is output to build/native/nativeCompile/barn.

Clean Build

./gradlew clean build

Running Locally

From JAR

java -jar build/libs/barn.jar --help

From Native Binary

./build/native/nativeCompile/barn --help

Development Mode

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

./gradlew run --args="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 Gradle project and import it
  5. Wait for Gradle sync to complete

Recommended plugins:

  • Kotlin
  • Gradle

Run configurations:

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

VS Code

  1. Install the Kotlin and Gradle extensions
  2. Open the barn folder
  3. The Gradle extension will detect the project

Common Tasks

Format Code

./gradlew ktlintFormat

Check Code Style

./gradlew ktlintCheck

Generate Documentation

./gradlew dokkaHtml

Output is in build/dokka/html/.

Dependency Updates

Check for outdated dependencies:

./gradlew dependencyUpdates

Troubleshooting

GraalVM Not Found

Ensure GRAALVM_HOME is set and GraalVM is on your PATH:

export GRAALVM_HOME=/path/to/graalvm
export PATH=$GRAALVM_HOME/bin:$PATH

Native Image Build Fails

Common causes:

  1. Reflection configuration missing: Add classes to reflect-config.json
  2. Resource not included: Add to resource-config.json
  3. Insufficient memory: Increase heap with -J-Xmx8g
./gradlew nativeCompile -Pnative.heap=8g

Tests Fail on Windows

Ensure line endings are consistent:

git config core.autocrlf input

Gradle Wrapper Issues

Regenerate the wrapper:

gradle wrapper --gradle-version 8.5

Out of Memory During Build

Increase Gradle daemon memory in gradle.properties:

org.gradle.jvmargs=-Xmx4g

Environment Variables

Variable Description
GRAALVM_HOME Path to GraalVM installation
JAVA_HOME Path to JDK (can point to GraalVM)
BARN_LOG_LEVEL Override log level during development

Next Steps

  • Releasing - How to create releases
  • CI/CD - Automated build and release workflows