redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 442 forks source link

Project 'myproject' is missing required Java project: 'somelib' #1191

Open safield opened 4 years ago

safield commented 4 years ago

I am using the vsocde-java extension with a gradle java project.

Receiving error "Project 'java_server' is missing required Java project: 'chesslib'

Commit: f359dd69833dd8800b54d458f6d37ab7c78df520 Date: 2019-11-25T14:54:40.719Z Electron: 6.1.5 Chrome: 76.0.3809.146 Node.js: 12.4.0 V8: 7.6.303.31-electron.0 OS: Linux x64 4.15.0-72-generic

My gradle configuration builds and runs fine, but the plugin complains still.

My build.gradle is as follows....

apply plugin: 'java'

// Use maven repository
repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation 'org.eclipse.jetty:jetty-servlet:9.4.19.v20190610'
    implementation 'org.eclipse.jetty:jetty-client:9.4.19.v20190610'
    implementation 'mysql:mysql-connector-java:8.0.16'
    implementation 'org.apache.commons:commons-dbcp2:2.7.0'
    implementation 'org.jdbi:jdbi3-core:3.10.1'
    implementation 'com.google.firebase:firebase-admin:6.11.0'
    compile 'com.google.apis:google-api-services-oauth2:v1-rev155-1.25.0'
    // implementation 'com.google.gms:google-services:4.3.3'

    compile project('chesslib')
    runtime files('../../chesslib/build/libs/chesslib-1.1.12.jar')
}

task runServer(type: JavaExec) {
   classpath = sourceSets.main.runtimeClasspath 
   main = 'ChessServer'
} 

task runClient(type: JavaExec) {
   classpath = sourceSets.main.runtimeClasspath 
   main = 'ChessClient'
   standardInput = System.in // without this, using Scanner on System.in won't work
}

task runCLITestApp(type: JavaExec) {
   classpath = sourceSets.main.runtimeClasspath 
   main = 'CLITestApp'
   standardInput = System.in
}

My settings.gradle is as follows...

include   ':chesslib'
project(':chesslib').projectDir = new File(settingsDir, '../../chesslib')
fbricon commented 4 years ago

Does this project import in Eclipse, with BuildShip (Gradle integration plugin) installed?

fbricon commented 4 years ago

Can you move the jar dependency inside the project folder?

sudofox commented 2 years ago

Also having this problem. gradle build works fine, but it still complains that one of the libs is missing

snjeza commented 2 years ago

@sudofox Could you, please, attach a sample project reproducing the error?

DavidGregory084 commented 1 year ago

Hi @snjeza I'm experiencing similar problems in this project if that helps? It's become worse since I renamed a bunch of modules in the root settings.gradle.kts in order to customise the artifact names.

everHannes commented 1 year ago

Loading my project I went into the same error. Gradle worked fine but VS Code showed include errors for my sub-projects. I however found that touching my settings.gradle.kts and accepting to sync the classpath fixes the error with next [ctrl+shift+b] workspace build.

"A build file was modified. Do you want to synchronize the Java classpath/configuration?" -> Yes

Whenever I recreate my workspace or rename the file, the error is back. So it is reproducable. Interestingly when I selected to "Always" update the classpath the error stopped to vanish. So in workspace settings I changed it back to "Interactive mode" and with next accepted popup sync the error is gone again.

The "Java: Reload Projects" command reliably fixes the error for me as well: { "key": "shift+alt+u", "command": "java.projectConfiguration.update", "when": "editorFocus" }

Hope that helps.

Edit: On another note, like DavidGregory084 I'm using Kotlin for the build files ( build.gradle.kts ).