You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MapStruct integration: mapper fails when MapStruct runs first and every marked bean is outside builderGenerationPackages #383
If MappingProcessor runs before BuilderProcessor and no @SimpleBuilder bean is inside simplebuilder.builderGenerationPackages, compilation fails:
No implementation was created for PersonMapper due to having a problem in the erroneous element other.PersonDto.
This reproduces on main and after #379. With builder-first ordering it compiles, and the mapper falls back to setters.
Cause
Round 1: MapStruct asks MapStructBuilderProvider for the bean's builder. The registry is not final yet, so it throws TypeHierarchyErroneousException and MapStruct defers the mapper.
BuilderProcessor plans no task, finalizes the registry in endRound, and writes no source.
No new sources means javac starts no further regular round, only the processing-over round. In 1.6.3, MapStruct's MappingProcessor does not retry deferred mappers there. It only reports the error.
If at least one in-scope builder is generated, a second round runs and the deferred mapper succeeds.
Proposed fix
MapStructBuilderProvider.isBuilderGenerationTarget checks only the marker annotations. Let it also apply the builderGenerationPackages scope (the provider already receives the processor options). A marked bean outside the scope can never get a builder, so the provider should return "no builder" right away instead of deferring.
Test
Add a MapStructSpiIntegrationTest case with mapStructCompiler(new MappingProcessor(), new BuilderProcessor()) and -Asimplebuilder.builderGenerationPackages=scoped. Check that the build succeeds, the mapper uses no builder, and it maps via setters.
Activity