jbuild 0.1.8

High-performance Java build tool supporting Maven and Gradle
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# jbuild Technical Specification

## Overview

jbuild is a high-performance build system for Java projects, written in Rust, supporting both Maven and Gradle build systems with enhanced performance optimizations and multi-language support.

## Version

**Current Version**: 0.2.0
**Rust Edition**: 2024  
**Minimum Rust Version**: 1.75.0

## Supported Platforms

- **Operating Systems**: macOS, Linux, Windows
- **Architectures**: x86_64, aarch64 (ARM64)
- **Java Versions**: 8, 11, 17, 21, 24+
- **Build Systems**: Maven, Gradle

## Core Features

### 1. Build System Support

#### Maven Support
- **POM Parsing**: Full pom.xml parsing with property interpolation
- **Lifecycle Execution**: validate, compile, test, package, install, deploy
- **Plugin System**: Plugin discovery, loading, and execution
- **Dependency Management**: Transitive resolution, conflict resolution, version ranges
- **Multi-Module**: Reactor builds with dependency ordering
- **Profiles**: Profile activation based on properties, OS, JDK version

#### Gradle Support
- **Build Script Parsing**: Groovy and Kotlin DSL support
- **Task Execution**: compileJava, test, jar, build, clean
- **Dependency Configurations**: implementation, api, compileOnly, runtimeOnly, testImplementation
- **Multi-Project**: settings.gradle, composite builds
- **Version Catalogs**: libs.versions.toml support

### 2. Performance Optimizations

#### Parallel Dependency Resolution
- **Implementation**: `src/resolver/parallel.rs`
- **Technology**: Rayon thread pool
- **Configuration**: Configurable max threads (default: CPU cores)
- **Performance**: 2-5x faster for projects with 50+ dependencies

**API**:
```rust
pub struct ParallelDependencyResolver {
    resolver: Arc<DependencyResolver>,
    max_parallel: usize,
}

impl ParallelDependencyResolver {
    pub fn new(resolver: DependencyResolver) -> Self;
    pub fn with_max_parallel(self, max: usize) -> Self;
    pub fn resolve_parallel(&self, dependencies: &[Dependency]) -> Result<Vec<Artifact>>;
    pub fn resolve_transitive_parallel(&self, dependencies: &[Dependency]) -> Result<Vec<Artifact>>;
}
```

#### Reactor Optimization
- **Implementation**: `src/core/reactor.rs`
- **Features**: Parallel batch execution, dependency graph analysis, critical path detection
- **Performance**: 3-5x faster for multi-module projects

**API**:
```rust
pub struct Reactor {
    projects: Vec<MavenProject>,
    dependency_graph: DependencyGraph,
}

impl Reactor {
    pub fn build_order(&self) -> Vec<&MavenProject>;
    pub fn execute_parallel<F>(&self, build_fn: F) -> Vec<BuildResult>;
    pub fn execution_stats(&self) -> ExecutionStats;
}
```

#### Persistent Build Cache
- **Implementation**: `src/core/persistent_cache.rs`
- **Storage**: JSON-based disk cache in `.jbuild/`
- **Hashing**: SHA-256 content hashing
- **Performance**: 10-50x faster incremental builds

**Cache Types**:
- Compilation cache (source → output mapping)
- Dependency cache (artifact resolution results)
- Test cache (test execution results)

**API**:
```rust
pub struct PersistentBuildCache {
    version: String,
    project_id: String,
    compilation_cache: HashMap<String, CompilationEntry>,
    dependency_cache: HashMap<String, DependencyEntry>,
    test_cache: HashMap<String, TestEntry>,
}
```

#### Incremental Build
- **Implementation**: `src/core/cache.rs`
- **Features**: Content-based fingerprinting, dependency tracking, smart invalidation
- **Performance**: 50-100x faster for single file changes

### 3. Multi-Language Support

#### Kotlin Compiler Integration
- **Implementation**: `src/compiler/kotlin.rs`
- **Compiler**: kotlinc via process invocation
- **Features**: Mixed Java/Kotlin compilation, compiler plugins
- **Supported Plugins**: all-open, no-arg, Spring

**Configuration**:
```rust
pub struct KotlinCompilerConfig {
    pub kotlin_home: Option<PathBuf>,
    pub jvm_target: String,
    pub api_version: Option<String>,
    pub language_version: Option<String>,
    pub progressive: bool,
    pub plugins: Vec<KotlinPlugin>,
}
```

#### Scala Compiler Integration
- **Implementation**: `src/compiler/scala.rs`
- **Compiler**: scalac via process invocation
- **Versions**: Scala 2.12, 2.13, 3.x
- **Features**: Mixed Java/Scala compilation, optimization flags

**Configuration**:
```rust
pub struct ScalaCompilerConfig {
    pub scala_home: Option<PathBuf>,
    pub scala_version: String,
    pub target: String,
    pub options: Vec<String>,
    pub optimize: bool,
}
```

#### Annotation Processing
- **Implementation**: `src/compiler/annotation_processor.rs`
- **Standard**: JSR 269
- **Supported Processors**: Lombok, MapStruct, Dagger, AutoValue, Immutables

**Configuration**:
```rust
pub struct AnnotationProcessorConfig {
    pub processor_path: Vec<PathBuf>,
    pub processors: Vec<String>,
    pub generated_source_dir: PathBuf,
    pub generated_class_dir: PathBuf,
    pub options: HashMap<String, String>,
    pub proc_only: bool,
}
```

### 4. Dependency Resolution

#### Resolution Strategy
- **Nearest Wins**: Shortest dependency path wins in conflicts
- **Version Ranges**: Support for Maven version range syntax
- **Exclusions**: Dependency exclusion support
- **Scope Management**: compile, provided, runtime, test, system

#### Repository Support
- **Local Repository**: `~/.m2/repository` (Maven), `~/.gradle/caches` (Gradle)
- **Remote Repositories**: Maven Central, custom repositories
- **Authentication**: Basic auth, token-based auth

### 5. Code Quality

#### Checkstyle Integration
- **Implementation**: `src/checkstyle/`
- **Parser**: tree-sitter-java
- **Checks**: 9 built-in checks
  - EmptyCatchBlock
  - EmptyStatement
  - MissingSwitchDefault
  - MultipleVariableDeclarations
  - SimplifyBooleanReturn
  - PackageName
  - TypeName
  - RedundantImport
  - LineLength
- **Configuration**: XML-based config file support
- **Output**: Checkstyle-compatible format

## Architecture

### Domain-Driven Design

jbuild follows DDD principles with 10 bounded contexts:

1. **Build System**: Core build orchestration
2. **Maven**: Maven-specific logic
3. **Gradle**: Gradle-specific logic
4. **Artifact**: Artifact management
5. **Compilation**: Java/Kotlin/Scala compilation
6. **Testing**: Test discovery and execution
7. **Packaging**: JAR/WAR creation
8. **Plugin**: Plugin system
9. **Configuration**: Build configuration
10. **Code Quality**: Linting and quality checks

### Layered Architecture

```
┌─────────────────────────────────────┐
│     Presentation Layer (CLI)        │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│    Application Layer                │
│   - BuildOrchestrationService       │
│   - ProjectInitializationService    │
│   - DependencyManagementService     │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│      Domain Layer                   │
│   - Aggregates                      │
│   - Domain Services                 │
│   - Value Objects                   │
└─────────────────────────────────────┘
┌─────────────────────────────────────┐
│    Infrastructure Layer             │
│   - Repositories                    │
│   - Compilers                       │
│   - File System                     │
└─────────────────────────────────────┘
```

## Performance Benchmarks

### Startup Time
- jbuild: ~10ms
- Maven: ~500ms
- Gradle: ~1000ms

### Dependency Resolution
| Project Size | Sequential | Parallel | Speedup |
|--------------|-----------|----------|---------|
| Small (< 10 deps) | 200ms | 150ms | 1.3x |
| Medium (10-50 deps) | 1000ms | 400ms | 2.5x |
| Large (> 50 deps) | 3000ms | 800ms | 3.8x |

### Multi-Module Builds
| Modules | Sequential | Parallel | Speedup |
|---------|-----------|----------|---------|
| 2 modules | 5s | 3s | 1.7x |
| 5 modules | 15s | 6s | 2.5x |
| 10 modules | 40s | 12s | 3.3x |

### Incremental Builds
| Scenario | Time | vs Full Build |
|----------|------|---------------|
| No changes | < 100ms | 50x faster |
| Single file | 500ms | 20x faster |
| 5 files | 2s | 10x faster |

## Dependencies

### Runtime Dependencies
- `quick-xml`: XML parsing
- `roxmltree`: XML tree parsing
- `serde`: Serialization
- `tokio`: Async runtime
- `reqwest`: HTTP client
- `rayon`: Parallel processing
- `num_cpus`: CPU detection
- `tree-sitter`: Code parsing
- `clap`: CLI parsing
- `anyhow`: Error handling

### Build Dependencies
- `tempfile`: Testing utilities

## Configuration

### Environment Variables
- `JAVA_HOME`: Java installation directory
- `KOTLIN_HOME`: Kotlin installation directory
- `SCALA_HOME`: Scala installation directory
- `JBUILD_MAX_THREADS`: Max parallel threads
- `JBUILD_CACHE_VERBOSE`: Enable cache logging
- `JBUILD_NO_CACHE`: Disable caching

### Configuration Files
- `jbuild.toml`: jbuild native configuration
- `pom.xml`: Maven configuration
- `build.gradle`: Gradle configuration
- `.jbuild/cache.json`: Build cache

## API Stability

### Public API (Stable)
- CLI commands and options
- Configuration file formats
- Cache file format (versioned)

### Internal API (Unstable)
- Rust module APIs
- Internal data structures
- Plugin interfaces (evolving)

## Testing

### Test Coverage
- **Total Tests**: 706+
- Comprehensive coverage across all modules
- Unit tests, integration tests, CLI tests, and checkstyle tests

### Test Categories
- Model parsing
- Dependency resolution
- Lifecycle execution
- Plugin system
- Checkstyle integration
- Multi-language compilation

## Future Roadmap

### Short Term (v0.3.0)
- Distributed cache support
- Remote cache server
- Enhanced CLI integration for new features
- Performance profiling tools
- JMH benchmark support (jbuild bench)

### Medium Term (v0.4.0)
- Groovy compiler support
- Clojure compiler support
- Build analytics
- Predictive caching
- Daemon mode for faster builds

### Long Term (v1.0.0)
- Full Maven plugin compatibility
- Full Gradle plugin compatibility
- IDE integration (LSP)
- Build visualization
- Native image support (GraalVM)

## Compliance

### Standards
- JSR 269: Annotation Processing
- Maven POM 4.0.0
- Gradle 7.x+ compatibility

### Licenses
- jbuild: Apache 2.0
- Dependencies: Various (see Cargo.toml)

## Support

### Supported JDK Vendors
- OpenJDK
- Eclipse Temurin
- Oracle JDK
- Amazon Corretto
- Azul Zulu
- IBM Semeru
- Microsoft OpenJDK
- GraalVM

### Supported Runtimes
- WildFly
- JBoss EAP
- WebSphere Traditional
- WebSphere Liberty
- Spring Boot
- Tomcat
- Jetty

## Limitations

### Current Limitations
- No GUI
- Limited Maven plugin execution (uses external Maven)
- No Gradle plugin execution (task-based only)
- No IDE integration yet
- No distributed builds

### Known Issues
- Some complex POM inheritance scenarios
- Limited Gradle Kotlin DSL support
- No incremental annotation processing yet

## Version History

### 0.2.0 (Current)
- Enhanced parallel dependency resolution (2-5x faster)
- Persistent build cache (10-50x faster incremental builds)
- Reactor optimization (3-5x faster multi-module builds)
- Kotlin compiler integration with plugins
- Scala compiler integration (2.12, 2.13, 3.x)
- Annotation processing (JSR 269: Lombok, MapStruct, Dagger, AutoValue, Immutables)
- Checkstyle integration (9 checks with tree-sitter parser)
- Cargo-like features (jbuild.toml, jbuild-workspace.toml, jbuild.lock)
- Project scaffolding (jbuild new, jbuild init)
- Enhanced dependency management (add, remove, update, search, tree, outdated)
- Java 24 support
- 469 tests passing

### 0.1.6
- Added parallel dependency resolution
- Added persistent build cache
- Added Kotlin compiler integration
- Added Scala compiler integration
- Added annotation processing support
- Enhanced reactor optimization
- Java 24 support

### 0.1.5
- DDD architecture implementation
- Enhanced Gradle support
- Checkstyle integration

### 0.1.0
- Initial release
- Basic Maven support
- Basic Gradle support
- CLI implementation