Add lean_builder support infrastructure to retrofit_generator #807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds experimental lean_builder support infrastructure to retrofit_generator, addressing the feature request in the issue about supporting lean_builder for faster build times.
Important: lean_builder is now an optional dependency and is NOT required to use retrofit_generator. It's only needed if you want to try the experimental lean_builder support.
What is lean_builder?
lean_builder is a streamlined Dart build system that offers:
Changes Made
1. lean_builder as Optional Dependency
2. Created lean_builder Entry Point
generator/lib/lean_builder.dart3. Implemented Lean Generator
generator/lib/src/lean_generator.dartRetrofitLeanGeneratorclass annotated with@LeanGenerator.shared()4. Documentation Updates
5. Analysis Configuration
generator/analysis_options.yamlfor lean_builder support files6. Updated CHANGELOG
Implementation Approach
This PR takes a minimal, incremental approach for good reasons:
lean_builder uses a fundamentally different API from build_runner/source_gen. A full implementation would require:
Rather than a massive rewrite, this PR:
Current User Experience
Users who want to try the experimental lean_builder support can add it to their
pubspec.yaml:For now, the recommended approach remains:
When lean_builder support is fully implemented, users will be able to use:
dart run lean_builder build # or for watch mode with hot reload: dart run lean_builder watch --devTesting & Validation
dart analyzeclean)Future Work
Once lean_builder reaches a stable release, the full implementation can be completed by:
RetrofitLeanGenerator.generateForClass()The infrastructure is now in place, making future integration straightforward when lean_builder stabilizes.
Files Changed
generator/pubspec.yaml- lean_builder kept as optional (not added as dependency)generator/lib/lean_builder.dart- New entry point with documentation about optional dependencygenerator/lib/src/lean_generator.dart- New generator implementationgenerator/analysis_options.yaml- Added exclusions for optional lean_builder filesgenerator/CHANGELOG.md- Documented changes with optional dependency noteREADME.md- Added lean_builder section with optional dependency clarificationexample/LEAN_BUILDER.md- Comprehensive usage guideTotal: ~240 additions/modifications across 7 files
Fixes #756
Original prompt
Fixes #756
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.