mapstruct and gradle configuratoin issue in Intellij IDEA

mapstruct eclipse gradle
mapstruct gradle
mapstruct and lombok issue
mapstruct eclipse cannot find implementation for
mapstruct maven-processor-plugin
plugin with id net ltgt apt not found
mapstruct java 11
mapstruct lombok

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

intellij-idea: mapstruct and gradle configuratoin issue in Intellij IDEA, Regression intellij 2019.2 for annotation processors (lombok, mapstruct, ) Information:java: compiler message file broken: key=compiler.misc.msg.bug you import, it is taking your "default" configuration (since tar.gz was not containing .idea). The only solution was to delegate build/test tasks to gradle, but not all tests  mapstruct-idea is the name of the repository that you can watch and create issues for. The plugin is not yet published as it is WIP. Currently there is only support for autocompletion for componentModel and rudimentary auto-completion and go to declaration for source and target .

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.

(lombok, mapstruct, ) : IDEA-220430 - YouTrack, of MapStruct is the early feedback on problems with the mapping configuration. your Maven or Gradle project, IntelliJ may or may not pick it up automatically. you need to configure IntelliJ manually until the feature request IDEA-150621  mapstruct-idea. An IntelliJ IDEA plugin for working with MapStruct. What is MapStruct? Features; Requirements; Building from Source; Licensing; What is MapStruct? MapStruct is a Java annotation processor for the generation of type-safe and performant mappers for Java bean classes. To learn more about MapStruct have a look at the mapstruct repository or the website

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"

IDE Support – MapStruct, You work with Gradle to build your application and would like to make use of This sort of issue can be avoided by setting up the processor separately. It's a good idea to declare a property which holds the language level. a separate dependency configuration which contains the MapStruct processor  MapStruct is an annotation processor. This means that the build tools java compilers are doing the compilation and invoking MapStruct and creating the generated classes. MapStruct itself does nothing for the integration with IntelliJ (in the sense of generating the mappers). Perhaps it is a bug in IntelliJ or a misconfiguration of Gradle / Maven.

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!

Using MapStruct with Gradle – MapStruct, Using https://github.com/mapstruct/mapstruct-examples/tree/master/mapstruct-​lombok sure about) is to add mapstruct-processor to the compile configuration in build.gradle Maybe we need to raise an issue with Jetbrains. Since Mapstruct version 1.3.0.Final is out, we are able to better integrate with Lombok Builder pattern. Mapstruct is a library that takes away a lot of boilerplate code for mapping between POJO’s. With Mapstruct there is no need for implementing the real mapping itself.

Converter implementation is not refreshed in IDEA · Issue #13 , Overview; Eclipse; Manual configuration tutorial; IntelliJ IDEA. Overview. As of Java 6, annotation processing became a part of the standard Java compiler. Item. Description. Gradle user home. Use this field to specify the location of stored Gradle caches, downloaded files, and so on. If Gradle location has been defined by the environment variables GRADLE_HOME or PATH, then IntelliJ IDEA deduces this location, and suggests this path as the default value.

Using annotation processor in IDE, git commit -m 'Initial commit' ), Intellij IDEA will automatically exclude It will tell you there are unmapped Spring configuration files, click on the + sign on the tweaks which currently only includes applying the MapStruct annotation processor. with Gradle you should delegate all IDE build/run actions to Gradle directly. I am evaluating Intellij IDEA 2019.1.3 Ultimate Edition. I am constantly having problems with gradle resolving dependencies, this may be in part because I am a gradle novice. Today's problem is that I can get gradle to resolve dependencies for compile group: 'com.nimbusds', name: 'nimbus-jose-jwt'. The two clues I get from the IDE are

Configuring Intellij IDEA, Gradle build file. Make some changes to the build.gradle file to include the dependencies for Lombok and Mapstruct. Listing 1. build  Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Comments
  • did you get it figured out?