We want to upgrade from 1.2.0.final to 1.3.0.final. We have 33 mappers in total, the generated code is checked into Git. Hence this makes it very easy to check the diff between 1.2.0 and 1.3.0 generated code. We have 5 mappers which use @AfterMapping. Three of them cause unit-tests for the generated mappers to fail. Did some digging and the failing MapperImp files are those which do use our manually created builders. It turns out that in the generated MapperImpl files calls for beforemapping and aftermapping do not exist. They do exist in the generated 1.2.0 files - which can't handle our builders.
I can reproduce the error with a very small mapper for which I've created a github gist. In file TelephoneBuilder I've disabled the build method and the generated code has beforemapping and aftermapping - included in the gist. By enabling the build method and generating code again you will notice that the builder is being used AND the beforemapping and aftermapping do disappear.
I've tried to disable the builders as I've read in the reference guide. We have a multi-project Gradle setup. In the project where the mappers are used I've created the following file: ./src/main/java/META-INF/services/org.mapstruct.ap.spi.BuilderProvider. Contents: org.mapstruct.ap.spi.NoOpBuilderProvider. removed src/main/generatedJava and created the mappers again. No difference, the builders are still being used. Did I place the file in the wrong place......
I've also tried "13.3. Custom Builder Provider" approach. In the generated NoOpBuilderProvider file BuilderProvider and BuilderInfo Eclipse complains with "BuilderProvider cannot be resolved to a type". The build.gradle file for the subproject contains:
ext.libraries = [
//mapstruct_jdk8: "org.mapstruct:mapstruct-jdk8:'1.3.0.Final'", // JDK for 1.2.0.final
mapstruct_jdk8: "org.mapstruct:mapstruct:'1.3.0.Final'",
mapstruct_processor: "org.mapstruct:mapstruct-processor:'1.3.0.Final'",
]
dependencies{
compileOnly libraries.mapstruct_jdk8
annotationProcessor libraries.mapstruct_processor
}. See also mapstruct/mapstruct-examples#66 for our Gradle 5 complete setup.
I hope you can use my example code to figure out what is going on. Perhaps its the way we create our builders or its a shortcoming in mapstruct.
We want to upgrade from 1.2.0.final to 1.3.0.final. We have 33 mappers in total, the generated code is checked into Git. Hence this makes it very easy to check the diff between 1.2.0 and 1.3.0 generated code. We have 5 mappers which use @AfterMapping. Three of them cause unit-tests for the generated mappers to fail. Did some digging and the failing MapperImp files are those which do use our manually created builders. It turns out that in the generated MapperImpl files calls for beforemapping and aftermapping do not exist. They do exist in the generated 1.2.0 files - which can't handle our builders.
I can reproduce the error with a very small mapper for which I've created a github gist. In file TelephoneBuilder I've disabled the build method and the generated code has beforemapping and aftermapping - included in the gist. By enabling the build method and generating code again you will notice that the builder is being used AND the beforemapping and aftermapping do disappear.
I've tried to disable the builders as I've read in the reference guide. We have a multi-project Gradle setup. In the project where the mappers are used I've created the following file: ./src/main/java/META-INF/services/org.mapstruct.ap.spi.BuilderProvider. Contents: org.mapstruct.ap.spi.NoOpBuilderProvider. removed src/main/generatedJava and created the mappers again. No difference, the builders are still being used. Did I place the file in the wrong place......
I've also tried "13.3. Custom Builder Provider" approach. In the generated NoOpBuilderProvider file BuilderProvider and BuilderInfo Eclipse complains with "BuilderProvider cannot be resolved to a type". The build.gradle file for the subproject contains:
ext.libraries = [
//mapstruct_jdk8: "org.mapstruct:mapstruct-jdk8:'1.3.0.Final'", // JDK for 1.2.0.final
mapstruct_jdk8: "org.mapstruct:mapstruct:'1.3.0.Final'",
mapstruct_processor: "org.mapstruct:mapstruct-processor:'1.3.0.Final'",
]
dependencies{
compileOnly libraries.mapstruct_jdk8
annotationProcessor libraries.mapstruct_processor
}. See also mapstruct/mapstruct-examples#66 for our Gradle 5 complete setup.
I hope you can use my example code to figure out what is going on. Perhaps its the way we create our builders or its a shortcoming in mapstruct.