microsoft / vscode-gradle

Manage Gradle Projects, run Gradle tasks and provide better Gradle file authoring experience in VS Code
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle
MIT License
124 stars 51 forks source link

java.import.gradle.offline.enabled setting is ignored #1508

Open astrelsky opened 3 months ago

astrelsky commented 3 months ago

Extension Name: vscode-gradle Extension Version: v3.13.5 OS Version: Windows 10 VSCode version: 1.89.0

Describe the bug The gradle plugin disregards the java.import.gradle.offline.enabled setting

To Reproduce

  1. Set java.import.gradle.offline.enabled to true since there is no Internet access.
  2. Java:Create Java Project...
  3. Gradle
  4. Select the current folder
  5. Groovy
  6. Enter whatever name you wish
  7. See [info] [gradle-server] Downloading https://service.gradle.org/distributions/gradle-8.8-bin.zip

Expected behavior Use the gradle I already have installed and in my path?

Output from "Gradle for Java" See reproduction steps.

Does the bug still exist if you disable all other extensions? Yes

Additional context I'm not 100% which plugin is really at fault for this here. However, if I already have the correct version of gradle installed and on my system path, then why insist on downloading it?

I have been using vscode for around 5 years now and using it with Java and gradle is STILL a nightmare.

jdneo commented 1 month ago

I'm not 100% which plugin is really at fault for this here. However, if I already have the correct version of gradle installed and on my system path, then why insist on downloading it?

I think it's not related with the gradle offline mode. It's more like a request that you hope to use your local installation to create a new gradle project.

The implementation now is created via tooling api I think, so the version of the created gradle project will be the same as the version of the tooling api that is used by the extension

astrelsky commented 1 month ago

I'm not 100% which plugin is really at fault for this here. However, if I already have the correct version of gradle installed and on my system path, then why insist on downloading it?

I think it's not related with the gradle offline mode. It's more like a request that you hope to use your local installation to create a new gradle project.

The implementation now is created via tooling api I think, so the version of the created gradle project will be the same as the version of the tooling api that is used by the extension

So, if I have gradle installed, the correct version I want to use, it's in my path and I've configured the vscode gradle home setting, have the gradle version setting set, have the gradle wrapper enabled setting unset and have the gradle offline mode set because I have no internet connection, vscode still has to download gradle?

It has been a while now so my memory is foggy but I'm pretty sure I tried everything and could only get it to work if I had the gradle wrapper in my project root.

Note this effects already created projects too. It's just easier to describe in steps that way.

astrelsky commented 1 month ago

Well I finally managed to get it to stop trying to download the gradle wrapper. So for those who find this here is how.

I deleted the existing ~/.gradle folder on an internet connected machine. I then opened up a gradle project in vscode and let it download the wrapper. I then closed vscode, killed the running gradle/java process, zipped up the ~/.gradle folder and copied it to my offline workstation. Then on my offline workstation I deleted the existing ~/.gradle folder (which already contained all the necessary files but whatever), unzipped the new .gradle folder and then went to ~/.gradle/wrapper/dist/gradle-8.8-bin/hashvalue/gradle-8.8/init.d and copied in the necessary gradle files so I can resolve dependencies.

It's a lot of unnecessary work for a system that has gradle setup and working already but at least I got it almost working. Everything seems to work fine except for the "Java Initialize Workspace - 21%" from the null Build Server Task that is stuck forever. It has been this way since the beginning of time with vscode though so I'll call it a success for now. I at least have the correct behavior for completions and hovers and stuff.

Edit: after about 40 minutes of initialization it finally finished for the first time ever. I had previously left it for over 24 hours of initialization like that without it finishing so I just assumed it wasn't going to finish.