'How to add lombak (annotationProcessor type) dependency in test suites plugin in gradle?
I have created a new test suite using jvm-test-suite plugin.
I have added few implementation type dependencies and it was working fine, no error was coming. But I also want to add lombak dependency in that test suite, I tried it with implementation keyword, after that I checked the project is getting compiled but at the runtime those annotations (Eg: SneakyThrows) of lombak are getting ignored and I was getting error.
After that I tried adding lombak dependency with annotationProcessor keyword which resulting is below given error at gradle sync. So basically it looks like annotationProcessor keyword and testAnnotationProcessor are not getting recognised and thus this error is coming.
Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'serverlessserver'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
Caused by: groovy.lang.MissingMethodException: No signature of method: build_aiuizpn3ddvrwt4slowy7mi4q.testing() is applicable for argument types: (build_aiuizpn3ddvrwt4slowy7mi4q$_run_closure4) values: [build_aiuizpn3ddvrwt4slowy7mi4q$_run_closure4@74ada7e2]
Gradle file snippet:-
testing {
suites {
test {
useJUnitJupiter()
}
customTest(JvmTestSuite) {
dependencies {
implementation project
... // other dependencies
annotationProcessor 'org.projectlombok:lombok:1.18.22' // adding this line is resulting in error message
}
}
....
}
}
Solution 1:[1]
Directly from the official lombok website.
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
}
Lombok annotations are applied during compilation, so it should be added in compileOnly stage, not in runtimeOnly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emil |
