mapstruct-examples icon indicating copy to clipboard operation
mapstruct-examples copied to clipboard

Add example of configuration arguments using Maven in Kotlin example

Open bsara opened this issue 7 years ago • 4 comments

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>
...

bsara avatar Dec 13 '17 19:12 bsara

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

gunnarmorling avatar Dec 13 '17 19:12 gunnarmorling

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")
    }
}

hemeroc avatar Jun 23 '18 15:06 hemeroc

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

`

<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
    <args>
        <arg>-Xjsr305=strict</arg>
        <arg>-Xjvm-default=enable</arg>
    </args>
</configuration>
<executions>
    <execution>
        <id>kapt</id>
        <goals>
            <goal>kapt</goal>
        </goals>
        <configuration>
            <sourceDirs>
                <sourceDir>src/main/kotlin</sourceDir>
                <sourceDir>src/main/java</sourceDir>
            </sourceDirs>
            <annotationProcessorPaths>
                <annotationProcessorPath>
                    <groupId>org.mapstruct</groupId>
                    <artifactId>mapstruct-processor</artifactId>
                    <version>${mapstruct.version}</version>
                </annotationProcessorPath>
            </annotationProcessorPaths>
            <annotationProcessorArgs>
                <annotationProcessorArg>
                    mapstruct.unmappedTargetPolicy=ERROR
                </annotationProcessorArg>
            </annotationProcessorArgs>
        </configuration>
    </execution>
</executions>

`

hellxcz avatar Jun 17 '19 10:06 hellxcz

thanks @hemeroc & @hellxcz

bsara avatar Jun 19 '19 19:06 bsara