lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

Can't find classpath in Gradle multi-projects' build

Open XO39 opened this issue 6 years ago • 2 comments
trafficstars

I'd like to first thank you for these fantastic mode. :)

I have many gradle multi-projects builds, something like this:

root_dir/
├── build.gradle.kts
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── project1
│   ├── project1.gradle.kts
│   └── src
│       ├── main
│       │   ├── java
│       │   │   └── Main.java
│       │   └── resources
│       └── test
│           ├── java
│           └── resources
├── project2
│   ├── project2.gradle.kts
│   └── src
│       ├── main
│       │   ├── java
│       │   │   └── mdbll
│       │   │       └── project2
│       │   │           ├── Main.java
│       │   │           └── Lib.java
│       │   └── resources
│       └── test
│           ├── java
│           │   └── mdbll
│           │       └── project2
│           └── resources
├── settings.gradle.kts
└── project3
    ├── project2.gradle.kts
    └── src
        ├── main
        │   ├── java
        │   │   └── mdbll
        │   │       └── project3
        │   │           ├── Main.java
        │   └── resources
        └── test
            ├── java
            │   └── mdbll
            │       └── project3
            └── resources

All projects' are connected though gradle build settings files, and some of them depend on the others. Although gradle project DOES exist, but I'm still getting:

LSP :: Classpath is incomplete. Only syntax errors will be reported

I've already created an empty .project file in the root of each project (e.g.: project1 directory ...), but still getting the same message.

How exactly does lsp-java determine a project's classpath when a project is created with -let's say- gradle? How should I configure my projects (including multi-projects like above example) so that classpath can be detected?

This is one of the few reasons I switched from meghanada to lsp.

XO39 avatar Feb 09 '19 11:02 XO39

The classpath detection is performed by jdtls server. It uses the same stuff like eclipse for importing the projects, reads the pom/gradle file, determines the modules and so on. I am not a gradle user myself. It is possible that your project structure is not supported and we should file a bug in JDT LS. You may test with VScode to verify that or give me a minimal example so I try it on my side. You may try something like http://www.thejavageek.com/2015/05/22/create-eclipse-project-with-gradle/ or import each module as a root which may fix your issue.

yyoncho avatar Feb 09 '19 13:02 yyoncho

OK, thanks a lot. I'll look more into it later and post back if something came up.

XO39 avatar Feb 09 '19 15:02 XO39