Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve imports when using includeBuild in package with v3.13.0 #1435

Closed
jjavery opened this issue Oct 18, 2023 · 7 comments
Closed

Can't resolve imports when using includeBuild in package with v3.13.0 #1435

jjavery opened this issue Oct 18, 2023 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@jjavery
Copy link

jjavery commented Oct 18, 2023

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

image

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.

@jjavery jjavery added the bug Something isn't working label Oct 18, 2023
@stefanrybacki
Copy link

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.

@jdneo
Copy link
Member

jdneo commented Oct 19, 2023

Thank you for reporting the issue. I can reproduce it, fix working in progress...

@jdneo jdneo modified the milestones: 3.13.1, 3.13.2, 3.13.4 Oct 19, 2023
@jdneo jdneo modified the milestones: 3.13.4, 3.13.5 Nov 9, 2023
@jdneo jdneo modified the milestones: 3.13.5, 3.13.6 Dec 1, 2023
@marekscholle
Copy link

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.

@jdneo
Copy link
Member

jdneo commented Mar 21, 2024

No accurate ETA, but we already have a PR at the build server side to support the composite build: microsoft/build-server-for-gradle#122

Should not be too far in the future I think.

@timolehto
Copy link

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
Screenshot from 2024-03-21 19-57-10

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 😢
image

@jdneo
Copy link
Member

jdneo commented Jul 8, 2024

The pre-release 3.14.2024070805 is released which contains the fix for the include build. You can install it and have a try.

@jdneo jdneo closed this as completed Jul 8, 2024
@jdneo
Copy link
Member

jdneo commented Jul 11, 2024

Sorry, the 3.14.2024070805 has some issues when the jvm used to launch gradle is < 17. I'm working on a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants