Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #245
Refs #243
This is still a POC.
What do we want?
We want vscode-gradle and vscode-java to support standard gradle builds with relative paths. There are real uses cases for it as reported by the linked issues.
Where are relative paths defined?
Relative paths can be set is various places, including:
java.import.gradle.user.home
build.gradle
def buildNumber = new File("build.num").text.toInteger() + 1
)gradle.properties
org.gradle.java.home=../../../../../Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
org.gradle.jvmargs=-Djavax.net.ssl.trustStore="../../../../modules/Common/security/cacerts" -Djavax.net.ssl.trustStorePassword=<trust-password>
How do we support relative paths?
In some cases we can normalise paths in the client (eg for vscode settings), but in the other cases we cannot.
The core of the problem is that, when running
./gradlew
from the root of the project, thecwd
that gradle uses is the root of the project, and relative paths work. When running gradle from a server, thecwd
is not the root of the project, and in the case of vscode, is usually an extension directory.So the fix/workaround, is to start the server from the root of the project, as demonstrated by the POC code in this PR. Think
cp.exec('/absolute/path/to/executable', { cwd: projectRoot })
The problem with this approach, is it doesn't support multi-root workspaces.