0

My Problem - QueryDsl and MapStruct only generate classes on maven install but i want it to re-generate on source code change (with springboot devtool auto restart). now it does nothing on source code change other than restart

My pom.xml as below

     ....
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${org.mapstruct.version}</version>
        </dependency>
      .....

<build>
        <plugins>
            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <version>1.1.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${org.mapstruct.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${org.projectlombok.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/generated-sources/annotations</outputDirectory>
                            <processors>
                                <processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>
                                <processor>org.mapstruct.ap.MappingProcessor</processor>
                                <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Intellij Setting

Annotation Processors

My Proccess - Before Spring-boot Start i have to clean then install maven due to Qclass and MapperImpl. Also after maven install because of Qclass error, got to check "Module output directory" on "Store generated sources relative to:"

and everytime i change mapstruct mapper file i have do above things yet again which is very annoying

i have tried this solution but it didnt work .. :X stackover flow solution

Please help Thx :)

Johnpark
  • 5
  • 2

1 Answers1

0

The best way to achieve that is to use the annotationProcessorPaths from the maven-compiler. It will do the job during the compilation phase of the project.

IntelliJ already configures the build appropriately based on the maven-compiler and will be able to detect your processors. I also know that in IntelliJ IDEA 2020.3 they are going to do some improvement around the processors that would improve the user experience.

Filip
  • 19,269
  • 7
  • 51
  • 60
  • thx for the comment but i already tried using annotationProcessorPaths as 2nd answer from https://stackoverflow.com/questions/44522494/how-to-make-querydsl-and-lombok-work-together# is there something i forgot ? – Johnpark Oct 08 '20 at 04:40
  • What happens when you do a change in the mapper class only? Is everything ok then. You could be affected by the problems fixed by the improvement I mentioned from IntelliJ – Filip Oct 08 '20 at 06:27