I have a project using gradle, and have mapstruct as one of dependency. everytime I tried to build project, it failed. I guess it is because Mapstruct will generate impl class that gradle was not able to find. Can anyone help me how to configure this in intellij IDEA?
Thanks
This works for me
In intellij IDEA go to
File | Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner
Enable Delegate IDE build/run actions. Ref :- https://www.jetbrains.com/idea/whatsnew/#v2016-3-gradle
In build.gradle
buildscript {
...
}
plugins {
id 'net.ltgt.apt' version '0.9'
}
apply plugin: 'idea'
apply plugin: "net.ltgt.apt"
dependencies {
...
compile 'org.mapstruct:mapstruct-jdk8:1.1.0.Final'
apt 'org.mapstruct:mapstruct-processor:1.1.0.Final'
}
After Adding this configuration Run your project you can see your generated files in build/generated folder
From Mac OS
Another setting I found helpful was to uncheck "Create separate module per source set" File | Settings | Build, Execution, Deployment | Build Tools | Gradle
Uncheck "Create separate module per source set"
Hey there everyone I had the same issue and found a clean way of solving this issue. I am using two libraries that require annotation processing (Lombok and MapStruct).
Also my IntelliJ is 2019.1 (update yours in case it's older) and Gradle 5.2.1.
First let's configure IntelliJ:
- Disable Annotaion Processing in Settings, since we're going to delegate everything to Gradle:
- Delegeate IDE actions to Gradle:
Last step is to configure your dependencies correctly in Gradle.
- Dependencies section in Gradle:
Now you can execute the Build and Run from both command line and IDE.
Cheers!
来源:https://stackoverflow.com/questions/38947569/mapstruct-and-gradle-configuratoin-issue-in-intellij-idea