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
IntelliJ IDEA xml file located in the root folder. IDEA then will load MapStruct, resolve all dependencies and compile the source. If so, open the preferences window, navigate to Compiler -> Annotation processor and untick checkbox “Enable annotation processing” at “Annotation profile for mapstruct-integrationtest”.
Press Alt+Insert to open the Generate context menu. From the context menu, select Add dependency. In the Dependencies tool window, in the search field, start typing the name of your dependency. In the list of results select the one you need and click Add.
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
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:
Last step is to configure your dependencies correctly in Gradle.
Now you can execute the Build and Run from both command line and IDE.
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With