When using a Gradle project, the Java Language Server does not seem to play nice when compileOnlyApi is used as a dependency type. Multiple errors occur as to the Java Language Server, the dependency is not resolved despite Gradle being able to build the project without issues. The same seems to occur for compileOnly.
See https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph for definitions.
The following is an example of a repo with the issue: https://github.com/GeyserMC/Floodgate
Environment
- Operating System: Ubuntu 20.04.4 LTS
- JDK version: 1.8
- Visual Studio Code version: 1.74.3
- Java extension version: 1.14.0
Steps To Reproduce
- Clone a repo with the issue (e.g. https://github.com/GeyserMC/Floodgate)
git clone https://github.com/GeyserMC/Floodgate
- Open the repo in VSCode and attempt to build with the Java Language Server
- Observe that there are unresolved imports in the
database module.
- In one of the submodules for
database, for example, database/mongo/build.gradle.kts, change the dependency type from provided (which is defined here as an alias for compileOnlyApi) to api.
val mongoClientVersion = "4.4.1"
dependencies {
api(projects.core)
// provided(projects.core)
implementation("org.mongodb", "mongodb-driver-sync" , mongoClientVersion)
}
description = "The Floodgate database extension for MongoDB"
relocate("com.mongodb")
relocate("org.bson")
- Clean the Java Language Server Workspace from the command palette, and select
Load & Delete when prompted to relaunch VSCode.
- After allowing the project to build, observe that the submodule
database/mongo no longer contains missing dependencies.
Please attach a sample project reproducing the error: https://github.com/GeyserMC/Floodgate
Please attach logs: https://gist.github.com/Kas-tle/38ac89a54417f5b248f1a5fad3d28268
Current Result
Gradle projects with dependencies marked compileOnly/compileOnlyApi incorrectly show missing imports as the Java Language Server fails to resolve the dependencies.
Expected Result
The Java Language Server can correctly resolve compileOnly/compileOnlyApi dependencies.
Additional Informations
N/A
When using a Gradle project, the Java Language Server does not seem to play nice when
compileOnlyApiis used as a dependency type. Multiple errors occur as to the Java Language Server, the dependency is not resolved despite Gradle being able to build the project without issues. The same seems to occur forcompileOnly.See https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph for definitions.
The following is an example of a repo with the issue: https://github.com/GeyserMC/Floodgate
Environment
Steps To Reproduce
databasemodule.database, for example,database/mongo/build.gradle.kts, change the dependency type fromprovided(which is defined here as an alias forcompileOnlyApi) toapi.Load & Deletewhen prompted to relaunch VSCode.database/mongono longer contains missing dependencies.Please attach a sample project reproducing the error: https://github.com/GeyserMC/Floodgate
Please attach logs: https://gist.github.com/Kas-tle/38ac89a54417f5b248f1a5fad3d28268
Current Result
Gradle projects with dependencies marked
compileOnly/compileOnlyApiincorrectly show missing imports as the Java Language Server fails to resolve the dependencies.Expected Result
The Java Language Server can correctly resolve
compileOnly/compileOnlyApidependencies.Additional Informations
N/A