How do I completely disable using "builders" in MapStruct? I don't want to use them at all as they are causing all kinds of issues for me.
I created the service file under META-INF (I would prefer a way to assign it to the mapping builder= but I did not see any examples how to do it right in code).
It is still trying to use Immutables "builder" instance instance of the "ModifiableXXX" instance I want to map to. I'd even take a way of forcing it to the modifiable type if that is available.
In another mapping, using an update the ModifiableXXX (with @AfterMapping and @MappingTarget) approach works.
My mapper looks like this right now:
@Mapper
public interface MongoProjectMapper
{
ModifiableProject mapModel(MongoProject project);
@AfterMapping
ModifiableProject updateProject(MongoEntity e, @MappingTarget ModifiableProject p);
}
Completely disabling builders is possible via the NoOpBuilderProvider
. You need to create a org.mapstruct.ap.spi.BuilderProvider
file in the META-INF/services
directory with org.mapstruct.ap.spi.NoOpBuilderProvider
as it’s content. This will completely disable the builders.
There is a feature request to make this more granular and disable it via @BeanMapping
or on the mapper level. Have a look at mapstruct/mapstruct#1661