jbuild
A high-performance Rust implementation of Java build tools, supporting both Maven and Gradle while leveraging Rust's performance and safety guarantees.
Overview
jbuild provides a complete Rust implementation of Java build systems, maintaining compatibility with:
- Maven: Project Object Model (POM) and build lifecycle
- Gradle: Build scripts and dependency management
The tool aims to provide faster builds through Rust's performance while maintaining full compatibility with existing Java build configurations.
Comparison: jbuild vs Maven vs Gradle
| Feature | jbuild | Maven | Gradle |
|---|---|---|---|
| Language | Rust | Java | Groovy/Kotlin (JVM) |
| Startup Time | ~10ms | ~500ms | ~1000ms |
| Memory Usage | Low (~50MB) | High (~200MB+) | High (~300MB+) |
| Build File | pom.xml / build.gradle | pom.xml | build.gradle(.kts) |
| Dependency Resolution | Shared resolver | Maven Resolver | Gradle Resolver |
| Parallel Builds | Native async (tokio) | Limited | Task-level |
| Incremental Builds | ✅ Built-in | ✅ Plugin-based | ✅ Native |
| Build Cache | ✅ Local | ❌ (requires plugin) | ✅ Local + Remote |
| Multi-module | ✅ Both systems | ✅ Reactor | ✅ Composite builds |
| Plugin Ecosystem | Maven plugins (via fallback) | Extensive | Extensive |
| Configuration | XML / Groovy DSL | XML only | Groovy/Kotlin DSL |
Key Advantages of jbuild
- Performance: Native Rust binary with no JVM startup overhead
- Memory Efficiency: Significantly lower memory footprint
- Unified Tool: Single binary supports both Maven and Gradle projects
- Modern Architecture: Async I/O, parallel execution, trait-based design
- Cross-Platform: Native binaries for all major platforms
Project Structure
The project is organized as a single crate with all modules under src/:
- model/: POM/Gradle file parsing and data structures
- artifact/: Artifact handling and coordinates
- core/: Core execution engine and lifecycle
- resolver/: Dependency resolution
- settings/: Settings and configuration management
- plugin_api/: Plugin API definitions
- compiler/: Java compiler integration (javac invocation, classpath management)
- packaging/: JAR/WAR file creation and packaging
- testing/: Test discovery, execution, and reporting
- main.rs: Command-line interface
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)
- ✅ 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)
- ✅ 218 tests passing (unit, integration, multi-module)
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
11
11
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 = '11'
targetCompatibility = '11'
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
# For Maven projects
# For Gradle projects
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) |
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
See ARCHITECTURE.md for detailed architecture documentation.
The architecture is inspired by Gradle's platform-based design. See GRADLE_LEARNINGS.md for architectural patterns we're adopting.
Key Design Patterns
- Trait-based abstractions: Core components use traits for testability
- Builder patterns: Complex objects use fluent builders
- Custom error types: Comprehensive error handling with
MavenError - Dependency injection: Supports mock implementations for testing
License
Licensed under the Apache License, Version 2.0.