mapstruct / mapstruct/mapstruct

MapStruct cannot find class generated by @KotlinBuilder when using @AfterMapping

Open
#2,049 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
7.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Using:
api 'org.mapstruct:mapstruct:1.3.1.Final'
kapt 'org.mapstruct:mapstruct-processor:1.3.1.Final'
api "com.github.pozo:mapstruct-kotlin:1.3.1.1"
kapt "com.github.pozo:mapstruct-kotlin-processor:1.3.1.1"

Issue:
The target Product is a kotlin data class with @KotlinBuilder.
This works: fun mapToModel(source: ProductDto): Product
But when adding this

    @AfterMapping
    fun afterMapToProduct(source: ProductDto, @MappingTarget builder: ProductBuilder) {
       // fun stuff
    }

Then the ModelMapperImpl class contains the package import: import error.NonExistentClass;

When I don't have this @AfterMapping the impl class correctly contains
import dk.bnr.androidbooking.model.product.ProductBuilder;
and correct building method.

I suspect its a mapstruct issue, but I'll cross-post issue 7 in KotlinBuilder with link to here, in case I'm wrong

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the MapStruct and KotlinBuilder dependencies listed in the report, with the Product data class, ProductDto, @KotlinBuilder, and @AfterMapping method. Compare the generated ModelMapperImpl output with and without @AfterMapping, focusing on the ProductBuilder import. Done means the generated implementation resolves the builder class instead of importing error.NonExistentClass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.