Stop generating metadata files at project's root - #1900
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: Sheng Chen <sheche@microsoft.com>
Signed-off-by: sheche <sheche@microsoft.com>
Signed-off-by: sheche <sheche@microsoft.com>
Signed-off-by: sheche <sheche@microsoft.com>
rgrunber
left a comment
There was a problem hiding this comment.
Change is working well for me. Played around with java.settings.url outside workspace, and within, and couldn't see any breakage.
That's currently a system property. It should be more configurable. We have a large source code base which is modified by many different editors/IDEs. This change would break VS Code users unless the setting is detected somehow at startup/during import. |
|
@guw Because the file system contribution will take effect at very begin before the server and client start communication via LSP. So it is a system property instead of a preference. I don't think the change will break the users because we considered the compatibility in implementation:
In the code base you mentioned:
If in your implementation, you want to deal with those metadata files. You can use the standard API to do it. For example if you want to update the project nature, use: If you do want to get the file instance of the metadata files, for example, for the |
Signed-off-by: Sheng Chen <sheche@microsoft.com>
testforstephen
left a comment
There was a problem hiding this comment.
LGTM. Have a try, it works with Maven/Gradle/Invisible project.
|
Feel free to combine the commits and merge when ready. |
lsp-java used to treat this as a configuration property of jdtls. However it is not a standard lsp configuration property. Instead it must be passed as a Java System Property on the command line invoking jdtls. See [JLFsUtils.java](https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.filesystem/src/org/eclipse/jdt/ls/core/internal/filesystem/JLSFsUtils.java#L192-L197) for how this property is read. Also see [eclipse-jdtls/eclipse.jdt.ls#1900](eclipse-jdtls/eclipse.jdt.ls#1900 (comment)) for an explanation of why this is a system property and not a regular LSP configuration property. Use a regular `defcustom` instead of using `lsp-defcustom` for declaring lsp-java-import-generates-metadata-files-at-project-root. Use this defcustom variable lsp-java--ls-command to pass an appropriate value for `java.import.generatesMetadataFilesAtProjectRoot`. With this change importing a Gradle-based java project into LSP will nolonger create `.classpath`, `.settings`, and `.project` entries at the root of the project.
lsp-java used to treat this as a configuration property of jdtls. However it is not a standard lsp configuration property. Instead it must be passed as a Java System Property on the command line invoking jdtls. See [JLFsUtils.java](https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.filesystem/src/org/eclipse/jdt/ls/core/internal/filesystem/JLSFsUtils.java#L192-L197) for how this property is read. Also see [eclipse-jdtls/eclipse.jdt.ls#1900](eclipse-jdtls/eclipse.jdt.ls#1900 (comment)) for an explanation of why this is a system property and not a regular LSP configuration property. Use a regular `defcustom` instead of using `lsp-defcustom` for declaring lsp-java-import-generates-metadata-files-at-project-root. Use this defcustom variable in `lsp-java--ls-command` to pass an appropriate value for `java.import.generatesMetadataFilesAtProjectRoot`. With this change importing a Gradle-based java project into LSP will nolonger create `.classpath`, `.settings`, and `.project` entries at the root of the project.
lsp-java used to treat this as a configuration property of jdtls. However it is not a standard lsp configuration property. Instead it must be passed as a Java System Property on the command line invoking jdtls. See [JLFsUtils.java](https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.filesystem/src/org/eclipse/jdt/ls/core/internal/filesystem/JLSFsUtils.java#L192-L197) for how this property is read. Also see [eclipse-jdtls/eclipse.jdt.ls#1900](eclipse-jdtls/eclipse.jdt.ls#1900 (comment)) for an explanation of why this is a system property and not a regular LSP configuration property. Use a regular `defcustom` instead of using `lsp-defcustom` for declaring lsp-java-import-generates-metadata-files-at-project-root. Use this defcustom variable in `lsp-java--ls-command` to pass an appropriate value for `java.import.generatesMetadataFilesAtProjectRoot`. With this change importing a Gradle-based java project into LSP will nolonger create `.classpath`, `.settings`, and `.project` entries at the root of the project.
resolve redhat-developer/vscode-java#618, requires redhat-developer/vscode-java#2153
There is a setting called
java.import.generatesMetadataFilesAtProjectRootto control whether the project metadata files will be generated at project root. By default it'sfalse, meaning those files will be hidden.Some known issues I found:
1. Buildship hard code the.settings/folder location: eclipse-buildship/buildship#11112. When calling .getLocation() from the metadata file(i.e.
project.getFile(".project").getLocation()), the file location always points to the project root. This is because the upstream implementation does not depend onFileStoreto resolve the location, seeFileSystemResourceManager#locationFor(). ButgetLocationURI()works fine.Signed-off-by: Sheng Chen sheche@microsoft.com