question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"import cannot be resolved" for gradle generated code

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AizenSosikecommented, Jul 7, 2022

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

0reactions
jeffkbkimcommented, Jul 20, 2021

afaik there’s no JAVA_PATH env var. and this doesn’t make sense to be added to JAVA_HOME nor PATH

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get my gradle-managed Java project in eclipse to ...
When I right click my project and click gradle>refresh dependencies, the console reports a "CONFIGURE SUCCESSFUL in 0s", however the opened ...
Read more >
How to generate source code during project import? - Buildship
I'm a happy command line user and use the gradle eclipse tasks frequently. Now that Buildship is 2.0 I thought it's time to...
Read more >
Generated sources are not picked up anymore in a Gradle build
I have a Gradle-based project in which we generate a QueryDSL class for each class that was annotated with javax.persistence.Entity. Up till IntelliJ...
Read more >
Cannot import api class from a generated openapi ... - GitHub
I've generated an artifact that I declare as a dependency, a kotlin-spring generated artifact, the dependency is resolved but I cannot import ......
Read more >
Using the Gradle build system in the Eclipse IDE - Tutorial
Eclipse does not automatically update the classpath, if the build.gradle file is updated. Select Gradle Refresh Gradle Project from the context ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found