mapstruct and gradle configuratoin issue in Intellij IDEA

北城余情 提交于 2019-12-04 03:25:48

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

Winner 19

From Mac OS

  1. Please remove build generated folder.
  2. Click Intellij IDEA => click Preferences... from menu => Select Build, Execution, Deployment => Select Gradle => Select Runner
  3. Tick into Deledate IDE build/run actions to gradle checkbox
  4. From run tests using: select Gradle Test Runner from dropdown list.

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:

  1. Disable Annotaion Processing in Settings, since we're going to delegate everything to Gradle:

  1. Delegeate IDE actions to Gradle:

Last step is to configure your dependencies correctly in Gradle.

  1. Dependencies section in Gradle:

Now you can execute the Build and Run from both command line and IDE.

Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!