Skip to content

Mapstruct doesn't work when either the DTO or the model is generated code. #1045

Description

@andrei-taras

My DTOs are generated.
Whenever I perform a clean in Eclipse (i.e. my generated DTOs get deleted), and MapStruct processor kick in first, then it sees that my DTOs don't exist yet, and it fails via org.mapstruct.ap.internal.model.common.TypeFactory, line 141 (in release 1.1.0.Final)

public Type getType(TypeMirror mirror) { if ( mirror.getKind() == TypeKind.ERROR ) { throw new AnnotationProcessingException( "Encountered erroneous type " + mirror ); } ... }

If I copy/paste the code in org.mapstruct.ap.MappingProcessor, and do the following changes (the catch clause : don't signal error, but throw a softer exception), it works (i.e. ignore all AnnotationProcessingException 's and leave the erroneous annotated code to be processed in the next round)
` private void processMapperTypeElement(ProcessorContext context, TypeElement mapperTypeElement) {
Object model = null;

    for ( ModelElementProcessor<?, ?> processor : getProcessors() ) {
        try {
            model = process( context, processor, mapperTypeElement, model );
        }
        catch ( AnnotationProcessingException e ) {
        	// Don't throw any more errors. Just delegate to the next round
        	throw new TypeHierarchyErroneousException(mapperTypeElement); 
        }
    }
}`

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions