Repository navigation
feat(options): add packageName option for generated builders - #306
Merged
AndreasIgel merged 3 commits intoSep 30, 2026
Merged
Conversation
Adds a new packageName member to @SimpleBuilder.Options that places generated builders into a configured package instead of the default one (the annotated type's package, resp. the @SimpleBuilderFor holder's package). - Effective package flows through ProcessingTarget.builderPackage, so builder TypeName, accessibility checks and file placement all follow the configured package consistently. - Members not reachable from the configured package (package-private and protected constructors/setters/getters) are treated as absent. - Invalid package names are rejected at compile time via SourceVersion.isName with a diagnostic on the affected element. - Also available as compiler option -Asimplebuilder.packageName. Resolves java-helpers#294 Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
A global -Asimplebuilder.packageName / -Dsimplebuilder.packageName would collapse all generated builders into a single package, so the option is now declared annotationOnly and ignored on the compiler-arg path. Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Moves the packageName validity check into BuilderConfigurationReader next to validateAccessModifiers - the resolved configuration is validated once for @SimpleBuilder targets and @SimpleBuilderFor holders. Co-Authored-By: Andreas Igel <andreas.igel@computacenter.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Issues: closes #294 · follow-up to #293 (#296)
Summary
Adds a
packageNamemember to@SimpleBuilder.Optionsthat places generated builders into a configured package instead of the default one. The default is unchanged: the annotated type's package for@SimpleBuilder, resp. the holder's package for@SimpleBuilderFor.packageNameis annotation-only (CompilerArgumentsEnum.annotationOnly): a global-Asimplebuilder.packageName/-Dvalue would collapse all generated builders into a single package, so it is deliberately ignored on the compiler-argument path.Implementation
BuilderConfiguration/CompilerArgumentsEnum:packageNamethreaded through as a regular string option on the annotation-parsing path.BuilderProcessor: aneffectiveBuilderPackage()helper resolves configuredpackageNameor falls back to the reporting element's package; it feedsProcessingTarget.builderPackageand the generated-builder registration, so builderTypeName, file placement, and theregisterGeneratedBuildermapping all agree.packageName_PackagePrivateConstructorIsNotReachable.SourceVersion.isNamerejects invalid package names with a diagnostic on the affected element.Tests
packageName_GeneratesBuilderIntoConfiguredPackage— for both@SimpleBuilderFor(holder) and@SimpleBuilderpackageName_Invalid_ProducesDiagnosticAndNoBuilderpackageName_PackagePrivateConstructorIsNotReachablepackageName_GlobalCompilerArgumentIsIgnored468 processor tests + 30 example tests green locally.
Documentation
#### packageNamesection indocs/CONFIGURATION.md(default, annotation-only semantics, accessibility, example)Optionsmember@SimpleBuilderFor+packageNamecalled out in the "How Simple Builders compares" sectionCloses #294