Reputation: 55
I am using mapstruct in multimodule maven project with Lombok. After setting the pom according the official doc, mapstruct did generate the mapper implementation correctly. But there will generate a extra folder in top module.
parent pom.xml:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<compilerArgument>-Xlint:deprecation</compilerArgument>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
web-base pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
<!-- additional annotation processor required as of Lombok
1.18.16 -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>
-Amapstruct.suppressGeneratorTimestamp=true
</arg>
<arg>
-Amapstruct.suppressGeneratorVersionInfoComment=true
</arg>
<arg>
-Amapstruct.verbose=true
</arg>
</compilerArgs>
</configuration>
</plugin>
web-base is the module where I use mapstruct and the src/main/resource... is the generated folder which I don't want. How can I change this location to its own module rather than in the top module? thanks.
Upvotes: 1
Views: 10141
Reputation: 21403
MapStruct does not have a control over the location of the generated source. MapStruct is an annotation processor and uses the Java Annotation Processor API to create the sources.
In order to change the location, you'll need to set the generatedSourceDirectory of the Maven Compiler Plugin
Upvotes: 5