"import cannot be resolved" for gradle generated code
When I open a gradle based project, jdtls loads successfully. However, I am seeing import errors from the server. More specifically, I see errors when importing generated code (created by gradle).
I can reproduce with an example project: https://github.com/apache/kafka
https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java#L267-L272 will show "cannot be resolved" errors once the jdtls server starts.
The import org.apache.kafka.common.message cannot be resolved
org.apache.kafka.common.message in this project is generated by a gradle task, and is located under
<project-root>/clients/src/generated/....
I see this behavior for both vscode and coc-java. is there a way to resolve this?
Have to be fixed by jdt.ls.
@chemzqm thanks for the response.
can you elaborate? is there anyway we can configure the client to add the generated directory?
Maybe add that folder to your JAVA_PATH could work.
afaik there's no JAVA_PATH env var. and this doesn't make sense to be added to JAVA_HOME nor PATH
I've got same issuse , I've changed java.configuration.maven.userSettings,its maybe some jar download failed with default maven-setting.xml cause,this's my solution:try CocCommand java.clean.workspace, its work fine with me
Use configuration java.configuration.maven.userSettings