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
}
}
....
}
}
CodePudding user response:
I communicated with gradle development team on their slack support channel. I got the answer to this question which solved my problem and hence I am posting it here for other people.
plugin donot provide direct annotation processor support inside testing/suites block by default as of now, the team is implementing it and probably they will support it in future releases.
You can still mention this annotation processor in outer most dependencies block of build.gradle file along with test suite name.
Example - build.gradle sample file
dependencies {
.....
// dependencies you already have in your project
// add this line. "customTest" here is the name of test suite you defined.
customTestAnnotationProcessor('org.projectlombok:lombok:1.18.22')
}
One more thing you have to make sure is that you have defined your test suites before this dependencies block in build.gradle file. otherwise, the annotationProcessor statement in dependencies do not recognise the test suite and will give error.
CodePudding user response:
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
.