Archived
- 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>
4.2 KiB
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
IntelliJ IDEA (Recommended)
- Open IntelliJ IDEA
- Select File > Open
- Navigate to the
barndirectory and open it - IntelliJ will detect the Gradle project and import it
- 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
- Install the Kotlin and Gradle extensions
- Open the
barnfolder - 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:
- Reflection configuration missing: Add classes to
reflect-config.json - Resource not included: Add to
resource-config.json - 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 |