Mapstruct Annotation Processor does not seem to work in Intellij with Gradle project
Finally it is working fine with Intellji 2018.1 CE. we don't need any apt plugins.
Here is updated gradle file
plugins {
id 'java'
}
repositories {
mavenCentral()
mavenLocal()
}
sourceCompatibility = JavaVersion.VERSION_1_8
dependencies {
compile group: 'org.mapstruct', name: 'mapstruct-jdk8', version: '1.2.0.Final'
compileOnly 'org.mapstruct:mapstruct-processor:1.2.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.2.0.Final'
compileOnly ("org.projectlombok:lombok")
testCompile 'junit:junit:4.12'
}
Please make sure following things are configured properly
Enable Annotations Processors( Preference->Build Execute Deployment ->Compiler->Annotations Processors )
MapStruct plugin
Lombok plugin
My build.gradle:
plugins {
id 'java'
id 'idea'
}
ext {
mapstructVersion = '1.2.0.Final'
}
dependencies {
// bean mapping
compile group: 'org.mapstruct', name: 'mapstruct-jdk8', version: mapstructVersion
compileOnly group: 'org.mapstruct', name: 'mapstruct-processor', version: mapstructVersion
annotationProcessor group: 'org.mapstruct', name: 'mapstruct-processor', version: mapstructVersion
}
Refresh and try to rebuild your project. If it doesn't work smoothly for you, proceed to the Troubleshooting section below.
Troubleshooting
If it doesn't work for you...
Enable Annotation Processors manually.
It seems to be a bug in IDEA related toannotationProcessor
configuration.Check out build output in "out/production/classes/generated" folder. If it's empty, try to rebuild your project. Make sure changes are applied by manually deleting contents of build output folders and modifying your mapper class before the rebuild.
$ rm -rf out build .gradle
Verify your Gradle build file by building and running the project outside of IntelliJ IDEA.
Try to delegate build actions to Gradle. I don't use this option, because annotation processor works for me anyway.
Update to IntelliJ IDEA 2018.3 or later.