Skip to content

Add support for creating workspace private project descriptions #1787

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Mar 22, 2025

Currently importing a project into eclipse requires the creation of a physical file name .project in the root of the project. this has several drawbacks for tools that automatically discover projects and import them for the user as it creates new files and possibly dirty their working tree. Other tools use a single folder for this purpose or don't require any permanent files in the working-tree itself. Even Eclipse has already such concept that is used when a project is located outside the workspace.

This now adds a new feature called "workspace private project" that only holds the basic information in the location file in the workspace directory, any additional information might be needed to restore by a tool that uses workspace private projects.

This is currently a draft what already works is that if one creates such a project is is open and can be used in eclipse, but there are some places that want to create / read the .project file (e.g. shutdown / restart).

@laeubi laeubi force-pushed the workspace_private_projects branch from 200ca6a to 7b2449a Compare March 22, 2025 07:24
@laeubi
Copy link
Contributor Author

laeubi commented Mar 22, 2025

I now added some more checks and it is now possible to create a private project and restart eclipse without a problem, the .project file is not created.

Copy link
Contributor

github-actions bot commented Mar 22, 2025

Test Results

  428 files   -   762    428 suites   - 762   17m 41s ⏱️ - 39m 23s
1 216 tests  - 2 957  1 142 ✅  - 2 984   9 💤  - 38   7 ❌ + 7   58 🔥 + 58 
3 041 runs   - 5 914  2 887 ✅  - 5 948  24 💤  - 96  16 ❌ +16  114 🔥 +114 

For more details on these failures and errors, see this check.

Results for commit 345db75. ± Comparison against base commit a791b17.

This pull request removes 2957 tests.
AllCompareTests AsyncExecTests ‑ testCancelOnRequeue
AllCompareTests AsyncExecTests ‑ testQueueAdd
AllCompareTests AsyncExecTests ‑ testWorker
AllCompareTests CompareFileRevisionEditorInputTest ‑ testPrepareCompareInputWithNonLocalResourceTypedElements
AllCompareTests CompareUIPluginTest ‑ testFindContentViewerDescriptorForTextType_StreamAccessor
AllCompareTests CompareUIPluginTest ‑ testFindContentViewerDescriptor_TextType_NotStreamAccessor
AllCompareTests CompareUIPluginTest ‑ testFindContentViewerDescriptor_UnknownType
AllCompareTests ContentMergeViewerTest ‑ testFFFX
AllCompareTests ContentMergeViewerTest ‑ testFFTX
AllCompareTests ContentMergeViewerTest ‑ testFFXF
…

♻️ This comment has been updated with latest results.

@laeubi laeubi force-pushed the workspace_private_projects branch 2 times, most recently from 5df01d9 to 50bfd88 Compare March 22, 2025 11:51
Currently importing a project into eclipse requires the creation of a
physical file name .project in the root of the project. this has several
drawbacks for tools that automatically discover projects and import them
for the user as it creates new files and possibly dirty their working
tree. Other tools use a single folder for this purpose or don't require
any permanent files in the working-tree itself. Even Eclipse has already
such concept that is used when a project is located outside the
workspace.

This now adds a new feature called "workspace private project" that only
holds the basic information in the location file in the workspace
directory, any additional information might be needed to restore by a
tool that uses workspace private projects.
@laeubi laeubi force-pushed the workspace_private_projects branch from 50bfd88 to 345db75 Compare March 22, 2025 15:50
@mickaelistria
Copy link
Contributor

Thank you for looking at this interesting topic.

It looks like as per javadoc in IProjectDescription, project.getFile(IProjectDescription.DESCRIPTION_FILE) is always expected to return such a file; that's one reason in JDT-LS hacks we've seen hacks about overriding the filesystem, and that later we changed (did we? but at least I remember I made it possible in Platorm) to be able to use a linked resource for .project.

I think we should aim to get the very minimal new API one can think of. Basically in this proposal, I'm not convinced that setWorkspacePrivate and equivalent are a necessary public API.
Concretely, I'm wondering what is best between getters/setters here and there and a new IProject.create(...) method with an extra flag instructing to create the .project in a workspace metadata rather than under the project.
For a newly created project, then isWorkspacePrivate just becomes IPath.fromOSString(IProjectDescriptionFileName).equals(project.getFile(DESCRIPTION_FILE_NAME).getLocation().makeRelativeTo(project.getLocation)); so we could deal with less getters.

@laeubi
Copy link
Contributor Author

laeubi commented Mar 23, 2025

Concretely, I'm wondering what is best between getters/setters here and there and a new IProject.create(...) method with an extra flag instructing to create the .project in a workspace metadata rather than under the project.

The flags are actually only flags passed to the creation of the Project resource itself and looking at org.eclipse.core.internal.resources.Workspace.createResource(IResource, int) only a few flags are actually supported here.

On the other hand the data in ProjectDescription are used to actually store the information about the project itself and we need access to these data on several places (e.g. ProjectDescription are cloned on some places) and we need to persist / restore that nature.

Also as you mentioned, there might be code that wants to access the project.getFile(IProjectDescription.DESCRIPTION_FILE) and would need to get a chance to know that the project itself is only workspace private.

That's the reason why I made this fact "public" and it was quite less changes than initially thought. This also includes to store basically the data currently in the .project file in the workspace area and allows recovery of deleted project files completely, currently Eclipse just creates an almost empty one.

For a newly created project, then isWorkspacePrivate just becomes IPath.fromOSString(IProjectDescriptionFileName).equals(project.getFile(DESCRIPTION_FILE_NAME).getLocation().makeRelativeTo(project.getLocation)); so we could deal with less getters.

I'm not completely sure about the intend here, this looks rather complicated and cumbersome to use as it requires knowledge of internal implementation details compared to a well defined getter.

Another approach would be to make the actual project file "virtual" and e.g. store it in the metadata area next to the location file, but for some reasons the Virtaul flag is currently completely disabled in 51c2f06

@mickaelistria
Copy link
Contributor

I'm not completely sure about the intend here, this looks rather complicated and cumbersome to use as it requires knowledge of internal implementation details compared to a well defined getter.

Most users really won't need to make the difference about whether the file is project-local or workspace-local once the project is created. So the flag would be usually useless.
The internal consumers can keep an internal private or package visible isWorkspacePrivate method to shortcut IPath.fromOSString(IProjectDescriptionFileName).equals(project.getFile(DESCRIPTION_FILE_NAME).getLocation().makeRelativeTo(project.getLocation)), that would be fine, but I just don't think we need extra project settings, and even less that we need it as API. Most users would indeed not need it as they would keep using the usual strategies to edit the project.
People who want to access the .project file can still do it the usual way, using the handle project.getFile(DESCRIPTION_FILE_NAME) or going through filesystem with project.getName(DESCRIPTION_FILE_NAME); that would still work anyway.

@laeubi
Copy link
Contributor Author

laeubi commented Mar 23, 2025

If you look at ProjectDescription you would see that each configurable property has a getter and setter. This is because one can even update the description later on, so it is not only for create a project itself.

@mickaelistria
Copy link
Contributor

If you look at ProjectDescription you would see that each configurable property has a getter and setter. This is because one can even update the description later on, so it is not only for create a project itself.

Indeed, but what I mean here is that how the project description is stored is not really a property of the project description. IMO, this property shouldn't be part of the description, creating a new Project.create(...) method would result in simpler code both for users and maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants