Skip to content

Custom compilers

Jugg supports extending its built-in incremental compilation flow through a custom compiler SPI. Custom compilers can insert logic before or after asset, resource, source, minify, DEX, and other stages to handle project-specific generation, transformation, or validation. This page describes integration capabilities and common insertion points. For loading and stage boundaries, see Custom compiler internals.

Supported integration methods

ScenarioCurrent supportUser-visible result
Local custom compiler JARSupportedLocal extension logic enters the Jugg compilation flow
Remote custom compiler JARSupportedThe remote extension participates in compilation after download and validation
Pre-stage processingSupportedCan consume or rewrite input before a built-in stage
Post-stage processingSupportedCan process artifacts after a built-in stage
Extension execution failsSupportedIf extension compilation logic throws an exception, the current task fails with a visible message

Integration

A custom compiler is provided as a JAR. The extension implements ICompilerCreator, which creates an ICompiler for the current compilation context. Jugg loads implementations from the JAR through SPI.

The project backend only needs to declare the JAR filename, path, and MD5 in the customCompilers configuration. The path can be an absolute local path, a path relative to the project directory, or an HTTP/HTTPS address.

NOTE

Custom compilers run inside the Jugg compilation flow. They are suitable for extending the incremental flow, not for replacing the complete Gradle task graph.

Trigger and result

text
Custom compiler configuration is available
  -> Load and validate the extension JAR
  -> Insert it into the configured compilation stage
  -> Participate in the current incremental compilation
  -> Pass successful artifacts to later stages

Choose an insertion point based on the user goal, not on when the JAR is loaded.

Common insertion points

GoalRecommended range
Process the current input and artifacts first or lastatFirst / atLast
Process assets and native libraries before or after their stagebeforeAsset / afterAsset
Process resources before or after their stagebeforeRes / afterRes
Process Java/Kotlin before or after their stagebeforeSource / afterSource
Process minification before or after its stagebeforeMinify / afterMinify
Process DEX before or after its stagebeforeDex / afterDex