Closed duquewu closed 7 years ago
It seems gradle's apt plugin not work well.After I remove the apt plugin and replace apt
with compileOnly
everything works well.
plugins {
id 'java'
id 'net.ltgt.apt' version '0.9'
}
...
dependencies {
compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
testCompile 'junit:junit:4.12'
apt "org.mapstruct:mapstruct-processor:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
}
plugins {
id 'java'
}
...
dependencies {
compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
testCompile 'junit:junit:4.12'
compileOnly "org.mapstruct:mapstruct-processor:${mapstructVersion}", "org.projectlombok:lombok:${lombokVersion}"
}
Hi, what are the steps to reproduce this issue? Are you using the Gradle wrapper checked into the project? Using this one (Gradle 3.4), everything works when running ./gradlew clean build
. Are you using another Gradle version perhaps?
To sum up for others that stumble to this issue. The problem was with the setup of IntelliJ. When using Gradle and IntelliJ make sure that you use Delegating IDE build/run actions to Gradle. That way everything will go via Gradle and will work correctly.
The reason why we recommend using the apt plugin is because by using that you won't expose the processor JAR on the compilation classpath. That way no code from the processor could accidentally be used within the compiled project.
Exception on mapstruct-lombok & mapstruct-on-gradle with gradle plugin net.ltgt.apt