-
Notifications
You must be signed in to change notification settings - Fork 55
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
Missing customization of GRADLE_USER_HOME #243
Comments
Thanks for the suggestion. Yep I will do this (when I've got some time). |
Hi, Just to report. We can configure environment variables for the vscode terminal via the workspace-level settings. See below "settings": { |
Great, yes this should work. Thanks for this tip. I'll add this info to the README. |
okie. |
Am re-opening just to to remind myself to update the README when I get some time |
Hi, just to feedback. VS Code: v1.44.2 The solution i highglighted in previous thread seems not working anymore. When the GRADLE_USER_HOME is as shown above, the GRADLE TASKS pane in vscode is empty. Can i confirm whether the vscode-gradle extension support variable set in the settings.json? Side note: Is this file org.eclipse.buildship.core.prefs generated by vscode-gradle extension? |
in addition, |
Hi, thanks for letting me know. I'll have a look.
Not, I believe this is generated by the Java Language support extension, as it uses the eclipse language server which in turn uses buildship.
I will consider to do this. |
Hi, "In VS Code 1.42 we will introduce a new hook resolveDebugConfigurationWithSubstitutedVariables in the extension API that receives the debug configuration with all variables resolved." Not sure if this will help in case in future, u might want to consider supporting variable expansion in the settings. |
I will however add support for |
great to hear that. Thanks! |
@hanct do you know if |
Actually it does seem to support relative paths, eg:
|
When setting an absolute path, and clearing the custom gradle user home directory, there's a conflict between gradle tasks and language server extensions as they both try to install the gradle executable. This error is thrown by the language server:
After the gradle wrapper is correctly downloaded, and the vscode window is restarted, the two extensions work correctly. This error is unexpected. I expected gradle to correctly handle these competing processes. One possible workaround is to wait for the java language server to be ready before getting build information. |
Hi.
Is it right for me to say that org.eclipse.buildship.core.prefs should NOT be manually modified? In other words, if i update the java.import.gradle.user.home in the settings.json, the vscode-java extension should sync this up to the prefs file? |
I got confused by some of the settings myself. There's two vscode settings:
As this is used by the language server, I don't have a very good understanding of the point of this file. Saying that, I have found that this file does not sync correctly with the vscode settings and can cause issues if not synced. To fix, I just delete the
IMO it should, but it doesn't always sync this file. As mentioned, delete the |
I didn't really answer your main question. From my testing, it seems to me that yes, |
The funny thing is when i change the value for java.import.gradle.user.home, it does not auto sync up with org.eclipse.buildship.core.prefs. Even restart vscode does not help. Anyway, i will raise this observation in vscode-java forum to understand more about how it works. |
@hanct did you delete the |
Hi. I delete it, then restart vscode. No use. However, i now realize by running "Java: Clean the Java language server workspace”, this command will clean up certain things then restart vscode. Then my prefs file is back again. |
Below is my finding after several round of testing Here is my step by step approach:
Query: Which extension results in the .gradle20 folder created in the project folder? vscode-java or vscode-gradle? |
Thanks, this matches my testing too.
vscode-java is doing this. It creates the directory, and successfully downloads the gradle binary into that directory, but is unable to execute it and throws that error you're seeing. The vscode-gradle extension is still using GRADLE_USER_HOME (default is $HOME/.gradle) |
The only biggest wish i have for vscode-java is that they support variable expansion for java.home and java.import.user.gradle.home. if they can support that, it is as good as using relative path. redhat-developer/vscode-java#1357 , i have previously raise request to support variable expansion for java.home, but no one seems to reply. Maybe they have difficulty supporting variable expansion, |
It's annoying I agree, but variable expansion in config/settings is a core missing feature in vscode, see: microsoft/vscode#46471 So I would not expect the extension authors to solve this themselves. Although they could make some reasonable assumptions, as i've done with #314, which is to check if the path is relative, and if so, prepend the absolute workspace folder path. I can understand if they don't want to do this though. |
Wau! I like what u have done: " to check if the path is relative, and if so, prepend the absolute workspace folder path". Have u suggest this method to them as an alternative to variable expansion? I don't see why they will not adopt your method. |
In fact, they can even create 2 additional settings ; The former is for absolute and the latter is for relative. If developer specify both, then the extension can choose one of them to be higher priority. Same for java.home But of course, if they do this, they will have to do that for each and every settings whose values is path, and they end up having to maintain lots of settings.. |
Personally I wold prefer not introducing new settings to accommodate relative/absolute. It's pretty easy to normalise a relative path from node.js so I might suggest this approach to them when I have some time. Anyways, it's not perfect, but i'm fairly happy with #314 now and will be merging soon. I don't want to release until I've added code to support all the other settings (eg |
Noted! |
Hey, this fix has been released. Can you update to the latest version and give it a test? |
Sure, but is your fix referring to that we are now able to use java.import.gradle.user.home and using relative path? If yes, but has vscode-java also able to support the relative path also? Cos if i set the java.import.gradle.user.home to relative path, vscode-gradle can works, but vscode-java will break. I would not be able to run the application. |
They're two separate issues. The fix is to support |
I might have found a fix for #245 and want to get that done first. If it turns out to be a good fix then I'll contribute the same fix for vscode-java |
Noted. I have done the test. Yes, it is successful! For the testing, I remove away the GRADLE_USER_HOME settings which i set in the settings.json. And ensure that the java.import.gradle.user.home is set to absolute path. Side note: e2d23231 Importing root project: 20% Refreshing '/codes'. [196/1000] |
Great thank you for testing! For the side note, yes this process is started by vscode-gradle. After a task is run, vscode-gradle tells vscode-java to update the java project configuration (see https://github.com/redhat-developer/vscode-java#available-commands) and that's what you're seeing. vscode-java is re-compiling necessary java files and updating the classpath. The reason why I've done this, is that gradle build tasks could generate new Java files (for example, generating Java classes from protobuf files). In this case, we want vscode-java to recognise the new Java files, compile them, and show the correct references in the editor. From my testing, usually this is a quick process, as vscode-java has already previously indexed all the Java files (on editor start), and should only compile new Java files. If this is taking a long time for you, potentially there's an error with vscode-java. In this case, you can open the java logs by running command "Java: Open all log files" and see if there are any exceptions in there. I can also potentially explore other ways to improve this. I wasn't aware this was causing issues for people. I'm gonna close this issue now and will work on the relative paths issue as part of #245 |
@badsyntax Thanks for this plugin, it looks great. But I tried to set the Here are the
And here is my workspace {
"terminal.integrated.env.osx": {
"GRADLE_USER_HOME":"/whatever",
},
} The thing is that this value is actually properly set when I open a new terminal window and I run the env command, but the actual value is empty when I print it from println("Env variable:")
println(System.getenv("GRADLE_USER_HOME")) By the way, I am using |
@zergeborg setting At the moment the only way to configure |
@badsyntax Thank you for replying quickly. I see. I was not aware of that change in #540 Thanks for improving it. |
Extension Name: vscode-gradle
Extension Version: v2.4.13
OS Version: windows 10
VSCode version: v1.43.2
May i know if there is any way to configure GRADLE_USER_HOME for this vscode-gradle extension to recognize? This extension seem to be missing the customization for this variable.
Note that I avoid setting this in my machine's environment variables, and would prefer to do it in the vscode instead. I have also installed vscode-java extension pack, and has configured java.import.gradle.user.home, but sadly no effect for vscode-gradle. This is not surprising as this setting is pertaining to the vscode-java extension , not vscode-gradle extension.
The text was updated successfully, but these errors were encountered: