nx icon indicating copy to clipboard operation
nx copied to clipboard

feat(maven): add batch executor for multi-task Maven execution

Open FrozenPandaz opened this issue 1 month ago • 13 comments

Current Behavior

The Maven plugin currently executes each Nx task individually, requiring a separate Maven process invocation for each target. This can result in significant performance overhead when running multiple Maven tasks, especially in monorepos with many modules.

Expected Behavior

With this change, the Maven plugin now supports batch execution of multiple tasks with identical phase/goals combinations in a single Maven process invocation. Tasks are intelligently grouped by their target configuration, reducing process overhead while maintaining per-task result tracking.

Changes Made

This implementation introduces:

Core Batch Executor (TypeScript)

  • maven-batch.impl.ts: Batch executor for multi-task execution
  • maven.impl.ts: Single executor for individual task execution
  • Updated schema to support batch execution configuration
  • TypeScript test coverage for both executors

Batch Runner (Kotlin)

  • NxMavenBatchRunner.kt: Main batch execution coordinator
  • MavenInvokerRunner.kt: Maven Invoker API integration
  • ArgParser.kt: Command-line argument parsing
  • MavenCommandResolver.kt: Maven executable detection (mvnw > mvn)
  • MavenBatchOptions.kt: Data models for batch configuration

Features

  • Task grouping by identical phase/goals combinations
  • Automatic Maven executable detection (mvnw > mvn)
  • Comprehensive error handling and result tracking
  • Foundation for future Kotlin/Java enhancements

Related Issue(s)

FrozenPandaz avatar Oct 23 '25 22:10 FrozenPandaz