LogoCyanPrint
ResolversExplanation

What are Resolvers

Understand what resolvers are and how they work

What Are Resolvers?

Resolvers are components that handle file conflicts when composing multiple templates together. When templates are layered, the same file path may be provided by multiple sources.

The Problem: File Conflicts

When you compose templates through:

  • Vertical layering - Dependencies between templates
  • Horizontal layering - Combining multiple templates

The same file may exist in multiple layers with potentially different content:

How Resolvers Work

Resolvers receive:

  1. Multiple file versions - All content from different template layers
  2. Layer information - Which template and layer each version came from
  3. Configuration - Merge strategy and other settings

And return a single merged file.

Example: JSON File Conflict

Layer 1: {"name": "app", "version": "1.0"} Layer 2: {"name": "app", "version": "2.0", "features": ["auth"]} Layer 3: {"name": "app", "features": ["auth", "logging"]}

Merged Result:

{
"name": "app",
"version": "2.0",
"features": ["auth", "logging"]
}

The key insight: Resolvers receive all versions and decide how to combine them. They don't care about which version came first—they receive everything and must produce a single output.

When to Use Resolvers

Use resolvers when you need to:

  • Combine configuration files - Merge JSON, YAML, or other config formats
  • Merge dependency lists - Combine package.json, requirements.txt
  • Aggregate content files - Combine .gitignore, Dockerfile
  • Custom merge logic - Implement domain-specific merge strategies

Resolver vs Processor

Resolvers and processors have different purposes:

AspectProcessorResolver
PurposeTransform individual filesMerge multiple file versions
InputSingle fileMultiple versions of same file
OutputTransformed fileSingle merged file
When UsedDuring template processingAfter processors complete
Port55515553

Execution Flow

Key Concepts

Layer Priority

Files from lower-numbered layers take priority:

  • Layer 0 = Base template
  • Layer 1 = First extension
  • Layer 2 = Second extension

Determinism

Resolvers must be deterministic:

  • Same inputs always produce the same output
  • No randomness or external state dependencies
  • Merge order must be consistent

Configuration-Driven

Resolvers receive configuration from templates

  • Merge strategy (concat, replace, distinct)
  • Custom settings per file type

Next Steps