How to exclude jdt api from classpath

Hi, I want to develop a plugin, which provides refactoring with jdt.
This is already working in unittest, but in a real gradle task it is not, because in gradle-api, which lays in generated-gradle-jars, there are jdt core classes, which collide with my version of jdt, which I use.
Can you please give me advice how to exclude this from classpath?
Thanks
Cheers
Markus

What version of Gradle are using?

Hi Benjamin,

I am using 3.5. But after further checks I can tell that is is no problem in productive environment. Calling the task from commandline gradle is no problem. The problem occurs in unittest if I create a project via ProjectBuilder and call the task directly in java. I have refactored to call the whole thing with gradle tooling api in my test, now it works for me.

Thank you
Cheers
Markus