tycho icon indicating copy to clipboard operation
tycho copied to clipboard

Support .settings folders as linked resources

Open sthdev opened this issue 2 years ago • 5 comments

It would be nice if Tycho would support .settings folders that are included as a linked resource in a project instead of a physical folder.

Background:

Our repositories are structured like this:

  • .settings
  • my.org.bundle
  • my.org.bundle.test
  • my.org.feature

The .settings folder is stored at the root of the repository in order to have on location for the settings of all projects. The individual projects do not have an own .settings folder but include the root .settings folder as a linked resource.

Linked resources are stored in the .project file of a project like this:

<projectDescription>
  <!-- other stuff -->
  <linkedResources>
    <link>
      <name>.settings</name>
      <type>2</type>
      <locationURI>$%7BPARENT-1-PROJECT_LOC%7D/.settings</locationURI>
    </link>
  </linkedResources>
</projectDescription>

This works fine in Eclipse but is not supported by Tycho. Tycho reports that no .settings\org.eclipse.jdt.core.prefs could be found in the individual project folders.

sthdev avatar Sep 19 '22 07:09 sthdev

@sthdev have you considered using a symbolic link instead?

Beside that, you might be interested in my proposal here:

  • https://github.com/eclipse-platform/eclipse.platform/issues/89

laeubi avatar Sep 19 '22 07:09 laeubi

Thanks for the hint. I'll try it out.

sthdev avatar Sep 19 '22 07:09 sthdev

Unfortunately, this does not work.

It is possible to create a directory junction (on Windows) named .settings in a project folder, which points to the .settings folder in the repository root. As expected, Eclipse treats it like a normal directory. However, EGit does that, too, i.e. it reports uncommitted files in each .settings folder of each project (i.e. the junctions). Moreover, EGit cannot commit the junction itself to the Git repository. Probably because Git does not support plain directories, only files. Therefore, when checking out the repository, the junction is lost.

sthdev avatar Sep 20 '22 11:09 sthdev

Git supports symbolic links:

https://stackoverflow.com/questions/58814356/how-to-create-symlink-for-files-in-git-repository

I just don't know how well this is supported with (j)git under windows.

laeubi avatar Sep 20 '22 12:09 laeubi

But only for files, not for folders.

sthdev avatar Sep 20 '22 12:09 sthdev

@sthdev can you provide an integration-test to demonstrate the issue?

laeubi avatar Oct 27 '22 15:10 laeubi

A colleague of mine has each separate .prefs file as linked resource, and that seems to work fine both in PDE and Tycho.

Bananeweizen avatar Oct 28 '22 13:10 Bananeweizen

"native" symbolic links should work fine; but .project (Eclipse) linked resources are not checked by Tycho so far.

mickaelistria avatar Nov 02 '22 09:11 mickaelistria

@laeubi which component is responsible for resolving the project settings? I am setting up an integration test and wondering how to name it or whether there already is an integration test for that component.

sthdev avatar Nov 04 '22 08:11 sthdev

@sthdev you can simply add a project in to the tycho-itest module and name it for example "linked-files": https://github.com/eclipse-tycho/tycho/tree/master/tycho-its/projects

laeubi avatar Nov 04 '22 08:11 laeubi

A colleague of mine has each separate .prefs file as linked resource, and that seems to work fine both in PDE and Tycho.

That would be too cumbersome. In our case, the *.pref files in the root .settings folder of each repository are defined in an Oomph setup model. When some settings change, the setup model is updated. As soon as someone, checks out a repository with that setup model, those new settings are rolled out to that repository, as well.

In case a new *.pref file is added, your suggestion would require to add it as a linked resource in all projects and all repositories. Doing that manually is too cumbersome and error-prone. I do not know if there is an automated way to do it but it would have to be triggered by the setup model.

sthdev avatar Nov 04 '22 08:11 sthdev

Added PR https://github.com/eclipse-tycho/tycho/pull/1626

sthdev avatar Nov 04 '22 13:11 sthdev

I do not know if there is an automated way to do it but it would have to be triggered by the setup model.

You can trigger any (checked in) launch config from Oomph. Instead of using Oomph for distributing project preferences, I have created a JUnit test to both copy the files from a template project and to also check some additional constraints for my setups at work. Has the added benefit of breaking the CI build if such constraints fail or if the template copy operation modifies the git working dir.

Bananeweizen avatar Nov 05 '22 17:11 Bananeweizen