jbuild
Cargo for Java - A modern, fast, and user-friendly build system for Java projects.
🎉 Major Milestone: Completed Domain-Driven Design (DDD) implementation with 285 tests passing! See DDD Implementation Complete for details.
☕ Java 24 Support: jbuild supports all Java versions from 8 to 24 and beyond! See Java Version Support for details.
The Problem
Java developers face significant friction with existing build tools:
- Slow startup: Maven takes 500ms+ and Gradle 1000ms+ just to start, even for simple commands
- High memory usage: JVM-based tools consume 200-300MB+ of RAM
- Complex configuration: Verbose XML (Maven) or DSL learning curve (Gradle)
- Poor developer experience: No simple
add dependencycommand, manual XML editing required - Tool fragmentation: Different commands and concepts between Maven and Gradle
Every mvn compile or gradle build wastes seconds waiting for the JVM to start.
The Solution
jbuild is a native Rust implementation that brings the Cargo experience to Java:
| Metric | jbuild | Maven | Gradle |
|---|---|---|---|
| Startup | ~10ms | ~500ms | ~1000ms |
| Memory | ~50MB | ~200MB | ~300MB |
| Add Dependency | jbuild add pkg |
Edit XML manually | Edit DSL manually |
| Create Project | jbuild new app |
mvn archetype:generate (interactive) |
gradle init |
Key Advantages
- 50x Faster Startup - Native binary, no JVM warmup
- 5x Less Memory - Efficient Rust implementation
- Parallel Builds - 3-5x faster multi-module builds with intelligent parallelization
- Smart Caching - 10-50x faster incremental builds with persistent cache
- Unified CLI - Same commands for Maven and Gradle projects
- Modern UX - Simple commands like
add,remove,search,tree - Zero Config - Works with existing
pom.xmlorbuild.gradle - Code Quality Built-in - Integrated Checkstyle linting
- Multi-Language - Java, Kotlin, Scala support with annotation processing
- All Java Versions - Supports Java 8 through 24 and beyond
Quick Start
# Install (coming soon)
# Create a new project
# Build and run
# Manage dependencies
Code quality
jbuild lint # Run Checkstyle checks jbuild test # Run tests
## Usage
### Project Management
```bash
jbuild new my-app # Create new Maven project
jbuild new my-app -b gradle # Create new Gradle project
jbuild new my-lib -t lib # Create library project
jbuild init # Initialize in existing directory
Workspace Support (Multi-Project Builds)
Building & Running
Dependency Management
Configuration
# Use jbuild.toml (auto-converted to pom.xml for build execution)
# jbuild.lock is auto-created from jbuild.toml for reproducible builds
Workspace Configuration
# jbuild-workspace.toml - Workspace configuration
= [
"core",
"api",
"app"
]
= [
"core",
"app"
]
[]
= "Highest" # Highest, Lowest, Fail
= "Highest" # Highest, Lowest, Fail
[]
= "my-workspace"
= "1.0.0"
= "Multi-project Java workspace"
Code Quality
Comparison: jbuild vs Maven vs Gradle
| Feature | jbuild | Maven | Gradle |
|---|---|---|---|
| Language | Rust | Java | Groovy/Kotlin (JVM) |
| Startup Time | ~10ms | ~500ms | ~1000ms |
| Memory Usage | ~50MB | ~200MB+ | ~300MB+ |
| Build File | pom.xml / build.gradle | pom.xml | build.gradle(.kts) |
| Add Dependency | jbuild add |
Manual XML edit | Manual DSL edit |
| Search Packages | jbuild search |
❌ | ❌ |
| Remove Dependency | jbuild remove |
Manual XML edit | Manual DSL edit |
| Dep Tree | jbuild tree |
mvn dependency:tree |
gradle dependencies |
| Package Info | jbuild info |
❌ | ❌ |
| Check Outdated | jbuild outdated |
❌ | ❌ |
| Update Dependencies | jbuild update |
Manual edit | Manual edit |
| Linting | jbuild lint |
Plugin required | Plugin required |
| Project Creation | jbuild new |
mvn archetype:generate |
gradle init |
| Multi-module | ✅ Both systems | ✅ Reactor | ✅ Composite builds |
| Incremental Builds | ✅ Built-in | ✅ Plugin-based | ✅ Native |
| Parallel Resolution | ✅ 2-5x faster | ❌ | ⚠️ Limited |
| Persistent Cache | ✅ 10-50x faster | ⚠️ Local only | ✅ Build cache |
| Kotlin Support | ✅ Native | ✅ Plugin | ✅ Native |
| Scala Support | ✅ Native | ✅ Plugin | ✅ Plugin |
| Annotation Processing | ✅ Built-in | ✅ Built-in | ✅ Built-in |
Project Structure
The project is organized as a single crate with all modules under src/:
- model/: Maven POM model, property interpolation, and model building logic
- artifact/: Artifact handling and coordinates
- core/: Core execution engine, lifecycle management, and build optimization
- resolver/: Dependency resolution (transitive, conflict, version range)
- settings/: Maven settings.xml parsing and configuration
- plugin_api/: Plugin API definitions and compatibility
- compiler/: Java compiler integration (javac invocation, classpath management)
- packaging/: JAR/WAR file creation and packaging
- testing/: Test discovery, execution, and reporting
- cli.rs: CLI definition (Clap structs)
- runner/: Command implementation logic (modularized into submodules)
- main.rs: CLI dispatcher (minimal entry point)
Status
This is an ongoing project. Both Maven and Gradle support are implemented with shared infrastructure.
Key Features Implemented:
- ✅ Maven POM parsing and model building
- ✅ Dependency resolution (local and remote repositories)
- ✅ Plugin loading and descriptor parsing
- ✅ Plugin dependency resolution
- ✅ Java compiler integration
- ✅ Lifecycle execution framework
- ✅ Plugin execution framework (with classpath setup)
- ✅ JNI integration for Java plugin execution (optional feature)
- ✅ External Maven process fallback for plugin execution
- ✅ JAR/WAR file packaging with manifest generation
- ✅ Test discovery and execution (JUnit, TestNG)
- ✅ Test reporting
- ✅ Profile activation logic
- ✅ Property interpolation
- ✅ Model validation
- ✅ Advanced dependency resolution (version ranges, conflicts, exclusions)
- ✅ Build optimization (incremental compilation, parallel execution)
- ✅ Parallel dependency resolution (2-5x faster with rayon)
- ✅ Persistent build cache (10-50x faster incremental builds)
- ✅ Reactor optimization (parallel multi-module builds)
- ✅ Plugin compatibility and configuration inheritance
- ✅ Gradle build script parsing (Groovy/Kotlin DSL)
- ✅ Gradle task execution (clean, compileJava, test, jar, build)
- ✅ Build system detection and unified CLI
- ✅ Gradle dependency resolution (integrated with shared resolver)
- ✅ Multi-project builds (settings.gradle support)
- ✅ Checkstyle integration (
jbuild lintcommand with 9 checks) - ✅ Multi-language support (Kotlin, Scala compilers integrated)
- ✅ Annotation processing (Lombok, MapStruct, Dagger, etc.)
- ✅ 469 tests passing (unit, checkstyle, CLI commands, integration)
See TODO.md for the current list of remaining work items and MIGRATION.md for migration details.
Example Projects
The examples/ directory contains sample projects demonstrating jbuild capabilities:
Maven Examples
examples/
├── simple-java-project/ # Single-module Maven project
│ ├── pom.xml
│ └── src/main/java/...
└── multi-module-maven/ # Multi-module Maven project
├── pom.xml # Parent POM
├── core/ # Core utilities module
├── api/ # API interfaces module
└── app/ # Application module
Sample Maven POM (examples/simple-java-project/pom.xml):
4.0.0
com.example
simple-java-project
1.0.0
jar
21
21
junit
junit
4.13.2
test
Gradle Examples
examples/
├── simple-gradle-project/ # Single-module Gradle project
│ ├── build.gradle
│ └── src/main/java/...
└── multi-module-gradle/ # Multi-module Gradle project
├── settings.gradle # Project settings
├── build.gradle # Root build script
├── core/ # Core utilities module
├── api/ # API interfaces module
└── app/ # Application module
Sample Gradle build script (examples/simple-gradle-project/build.gradle):
plugins
group = 'com.example'
version = '1.0.0'
sourceCompatibility = '21'
targetCompatibility = '21'
repositories
dependencies
Sample settings.gradle (examples/multi-module-gradle/settings.gradle):
rootProject.name = 'multi-module-gradle'
include ':core'
include ':api'
include ':app'
Building
# Build without JNI (uses external Maven process for plugins)
# Build with JNI support (enables direct Java class loading)
Running
# Modern Cargo-like commands (auto-detects build system)
# Dependency management
# Project creation
# Legacy mode (explicit build file)
# Generate shell completions
Supported Tasks/Goals
| Maven Goal | Gradle Task | Description |
|---|---|---|
compile |
compileJava |
Compile Java sources |
test-compile |
compileTestJava |
Compile test sources |
test |
test |
Run tests |
package |
jar |
Create JAR file |
clean |
clean |
Clean build outputs |
install |
- | Install to local repository |
| - | build |
Full build (compile + test + jar) |
Code Quality: jbuild lint
The lint command runs Checkstyle checks on Java source files:
# Check all Java files in src/main/java and src/test/java
# Check specific files or directories
# Use custom Checkstyle configuration
Available Checks:
- EmptyCatchBlock - Detects empty catch blocks
- EmptyStatement - Detects empty statements (standalone semicolons)
- MissingSwitchDefault - Detects switch statements without default case
- MultipleVariableDeclarations - Detects multiple variable declarations per statement
- SimplifyBooleanReturn - Detects boolean returns that can be simplified
- PackageName - Validates package naming conventions
- TypeName - Validates type naming conventions
- RedundantImport - Detects redundant imports
- LineLength - Detects lines exceeding maximum length (default: 120)
Testing
The project includes comprehensive unit tests and integration tests:
# Run all tests
# Run only unit tests
# Run integration tests
# Run with output
Test Structure
- Unit tests: Located in
src/modules with#[test]attributes - Integration tests: Located in
tests/directory - Mocks and fixtures:
src/testing_utils.rsprovides mock implementations for testing
Testing Utilities
The codebase provides several testing utilities in testing_utils:
MockArtifactRepository: In-memory artifact repository for testingMockDependencyResolver: Mock dependency resolver for controlled testingTestProjectBuilder: Fluent builder for creating test projects
Example usage:
use ;
Architecture & Design
jbuild follows Domain-Driven Design (DDD) principles with clean architecture:
┌─────────────────────────────────────┐
│ Presentation Layer (CLI) │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Application Layer ✅ │
│ - BuildOrchestrationService │
│ - ProjectInitializationService │
│ - DependencyManagementService │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Domain Layer ✅ │
│ - Aggregates (MavenProject, etc) │
│ - Domain Services (5 services) │
│ - Value Objects (15+ objects) │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Infrastructure Layer ✅ │
│ - LocalRepository │
│ - RemoteRepository │
└─────────────────────────────────────┘
DDD Implementation Status
Completed Phases (1-6):
- ✅ Phase 1: Shared Kernel (Version, FilePath, JavaVersion)
- ✅ Phase 2: Value Objects (15+ domain objects)
- ✅ Phase 3: Aggregate Roots (MavenProject, GradleProject)
- ✅ Phase 4: Domain Services (5 services)
- ✅ Phase 5: Repository Implementations (3 repositories)
- ✅ Phase 6: Application Services (3 services)
Test Coverage: 285 tests passing (100% pass rate)
Documentation
- ARCHITECTURE.md - Overall architecture
- Architecture Diagram - Visual system overview
- DDD Implementation Complete - Comprehensive DDD summary
- DDD Architecture - Domain model details
- Performance Optimizations - Parallel builds, caching, incremental compilation
- Multi-Language Support - Kotlin, Scala, annotation processing
- Java Version Support - Java 8-24+ support
- Phase 4 Summary - Domain Services
- Phase 5 Summary - Repositories
- Phase 6 Summary - Application Services
Key Design Patterns
- Repository Pattern: Trait-based abstraction for artifact storage
- Aggregate Pattern: Consistency boundaries (MavenProject, GradleProject)
- Value Object Pattern: Immutable, validated domain objects
- Domain Service Pattern: Stateless business logic encapsulation
- Dependency Injection: Trait-based for testability
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
The codebase follows Domain-Driven Design principles. See DDD Migration Guide for contributing guidelines.
License
Licensed under the Apache License, Version 2.0.