vscode-gradle
vscode-gradle copied to clipboard
Can't resolve imports when using includeBuild in package with v3.13.0
Extension Name: vscode-gradle Extension Version: v3.13.0 OS Version: macOS 13.6 VSCode version: v1.83.1
Describe the bug
Java imports of local packages can't be resolved when using the includeBuild feature in a gradle.settings file. This only occurs with vscode-gradle v3.13.0. Going back to v3.13.7 resolves the problems.
To Reproduce
I've created a repository that reproduces the problem here:
https://github.com/jjavery/vscode-gradle-includebuild-bug
Open vscode-gradle-includebuild-bug.code-workspace in VSCode, wait for the Java build, and observe the errors in the PROBLEMS panel.
Expected behavior
Expect to be able to use includeBuild to define a composite build of packages in a VSCode workspace.
Screenshots
Output from "Gradle for Java"
[info] [gradle-server] Server started, listening on 52758 [info] Gradle client connected to server [info] Java Home: /opt/homebrew/Cellar/openjdk@17/17.0.8.1/libexec/openjdk.jdk/Contents/Home [info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant [info] Gradle User Home: ~/.gradle [info] Gradle Version: 8.3 [info] Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
CONFIGURE SUCCESSFUL in 4s [info] Java Home: /opt/homebrew/Cellar/openjdk@17/17.0.8.1/libexec/openjdk.jdk/Contents/Home [info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant [info] Gradle User Home: ~/.gradle [info] Gradle Version: 8.3 [info] Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
CONFIGURE SUCCESSFUL in 651ms [info] Found 76 tasks [info] Build file opened: vscode-gradle-includebuild-bug/package-1/build.gradle [info] Build file opened: vscode-gradle-includebuild-bug/package-1/settings.gradle [info] Build file opened: vscode-gradle-includebuild-bug/package-1/build.gradle [info] Build file opened: vscode-gradle-includebuild-bug/package-1/settings.gradle
Does the bug still exist if you disable all other extensions?
Yes, although I didn't try it without Language Support for Java v1.23.0
Additional context
Unsure if relevant but all of my testing has been with a VSCode workspace. Each package is it's own folder in a single workspace.
We experience the same problem. It seems to be a problem with the new buildServer. Disabling it via "java.gradle.buildServer.enabled": "off" fixes the problem, however disables the new buildServer.
Thank you for reporting the issue. I can reproduce it, fix working in progress...
Hi, may I ask on progress / ETA for this issue?
It would be great if we could have includeBuild() working with VSCode and the "new build server" so that projects which – for w/e reason – need to glue several projects into composite build can benefit from the better and seamless IDE experience.
Thank you very much.
No accurate ETA, but we already have a PR at the build server side to support the composite build: https://github.com/microsoft/build-server-for-gradle/pull/122
Should not be too far in the future I think.
It's pretty wild that even if you create a regular java project with additional library modules and confirm it to work, but then take one of those modules and move it outside the project and create a symbolic link to the module instead the imports start to fail in VSCode.
I.e. do someting like this:
mkdir demo && cd demo && gradlew init
Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4] 2
Select implementation language:
1: C++
2: Groovy
3: Java
4: Kotlin
5: Scala
6: Swift
Enter selection (default: Java) [1..6] 3
Split functionality across multiple subprojects?:
1: no - only one application project
2: yes - application and library projects
Enter selection (default: no - only one application project) [1..2] 2
Select build script DSL:
1: Groovy
2: Kotlin
Enter selection (default: Groovy) [1..2] 1
Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no]
Project name (default: demo):
Source package (default: demo):
> Task :init
Get more help with your project: https://docs.gradle.org/7.4/samples/sample_building_java_applications_multi_project.html
BUILD SUCCESSFUL in 35s
2 actionable tasks: 2 executed
Confirm in VSCode the imports work fine
Then do this:
mv utilities ../. && ln -s ../utilities .
# and just to verify..
./gradlew test
BUILD SUCCESSFUL in 3s
18 actionable tasks: 14 executed, 4 up-to-date
After you have synchronized the Java classpath configuration the imports aren't working in the editor :cry:
The pre-release 3.14.2024070805 is released which contains the fix for the include build. You can install it and have a try.
Sorry, the 3.14.2024070805 has some issues when the jvm used to launch gradle is < 17. I'm working on a fix now.
Should be fixed in 3.15.0