mapstruct / mapstruct-examples

Examples for using MapStruct
Other
1.28k stars 512 forks source link

Add example of configuration arguments using Maven in Kotlin example #36

Open bsara opened 6 years ago

bsara commented 6 years ago

Can we get added to the pom.xml file in the kotlin example some configuration arguments?

Right now I have the following and it's not working...because kapt is being used rather than the maven compiler plugin for annotation processing (and after a lot of googling and searching, I can't find anything on how kapt processor args are meant to be formatted when using maven):

...
  <annotationProcessorPaths>
    <path>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct-processor</artifactId>
      <version>${mapstruct.version}</version>
    </path>
  </annotationProcessorPaths>
  <args>
    <arg>-Amapstruct.defaultComponentModel=spring</arg>
    <arg>-Amapstruct.unmappedTargetPolicy=IGNORE</arg>
    <arg>-Amapstruct.suppressGeneratorTimestamp=true</arg>
    <arg>-Amapstruct.suppressGeneratorVersionInfoComment=true</arg>
  </args>
...
gunnarmorling commented 6 years ago

Maybe you could ask in the Kotlin forum, user group etc. what's the correct way for passing processor arguments?

hemeroc commented 6 years ago

I had the same problem here with a kotlin/mapstruct/gradle projekt and ended up here. Finally I found a solution which I wanted to share:

kapt {
    correctErrorTypes = true
    arguments {
        arg("mapstruct.defaultComponentModel", "spring")
        arg("mapstruct.unmappedTargetPolicy", "ERROR")
    }
}
hellxcz commented 5 years ago

for kapt in maven here is working solution - working on mapstruct 1.3.0.Final

`

org.jetbrains.kotlin kotlin-maven-plugin ${kotlin.version} -Xjsr305=strict -Xjvm-default=enable kapt kapt src/main/kotlin src/main/java org.mapstruct mapstruct-processor ${mapstruct.version} mapstruct.unmappedTargetPolicy=ERROR `
bsara commented 5 years ago

thanks @hemeroc & @hellxcz