Skip to content
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

Simplify project synchronization #196

Merged
merged 22 commits into from
Dec 12, 2016
Merged

Simplify project synchronization #196

merged 22 commits into from
Dec 12, 2016

Conversation

donat
Copy link
Contributor

@donat donat commented Dec 4, 2016

No description provided.

oehme and others added 22 commits December 4, 2016 18:41
Up until now, the build command updater could not handle two build
commands with the same id but different arguments.

It is now simplified to the following behavior:

- If the Gradle model does not provide build commands, leave them alone
- If the Gradle model provides build commands, overwrite the existing
ones with those

This makes sure that the project accurately matches the Gradle model
while not breaking users on older versions.
This ensures that the Eclipse project faithfully matches the Gradle
project. If the Gradle version does not provide project nature
information, then the user-defined natures stay untouched.
Writing them to the .prefs file is confusing our users. They think that
they can customize them or that they are somehow important. In fact,
they are just internal state which doesn't make sense to expose to the
user and also should not be checked into version control.

Linked resources are workspace metadata, so persistent properties are a
good fit, since their lifecycle is also bound to the workspace.

The size limitation of persistent properties (2KB) should be acceptable,
since we store relative paths, not absolute ones.

If we actually encounter a real world project with so many linked
resources that this becomes an issue, we can use a custom file inside
our plugin's state location, similar to our classpath cache.
Writing them to the .prefs file is confusing our users. They think that
they can customize them or that they are somehow important. In fact,
they are just internal state which doesn't make sense to expose to the
user and also should not be checked into version control.

Derived resources are workspace metadata, so persistent properties are a
good fit, since their lifecycle is also bound to the workspace.

The size limitation of persistent properties (2KB) should be acceptable,
since we store relative paths, not absolute ones.

If we actually encounter a real world project with so many derived
resources that this becomes an issue, we can use a custom file inside
our plugin's state location, similar to our classpath cache.
The source folder updater used to keep source folders that were not
defined in Gradle. This could lead to a situation where the user defined
a folder that is in conflict with the Gradle model and can now no longer
synchronize. The user then needs to know how to remove the source folder
manually before the synchronize will work again.

The updater now removes folders that were not defined in Gradle. This
makes sure the Eclipse project matches the Gradle configuration.
The classpath container updater will now overwrite all containers if Gradle supports
container information. In case Gradle does not provide container information,
it will only update the JRE container based on the Java source settings.

This removes the need to remember which containers were user defined and
makes the project configuration match the Gradle configuration as closely as
possible.
Doing the whole synchronization in a single transaction lead to lots of
memory pressure in bigger projects. We originally introduced this
transaction because the tasks view could not handle rapid updates. This
has been fixed in the meantime and the view now behaves sanely even when
there are hundreds of "project added" events in short succession.
Adding or removing projects from the workspace should not trigger a
reload of the whole Gradle model. It should only be re-fetched if the
user explicitly requests it. Otherwise we'd reload the model twice
during project import.
The following has been changed by this commit:
- Use consistent naming in ClasspathContainerUpdaterTest
The new preference implementation automatically deletes the preferences
for a deleted project, but the tests expected that they remain at their
location.
- Rename ProjectPluginStatePreferenceStore and ProjectPluginStatePreferences
  to ModelPersistence and PersistentModel
- Rename loadProjectPrefs() method to loadModel()
- Merge how project change events are handled in the core and in the ui plugin
- Add test coverage for ProjectChangeListener
- Add test coverage for ModelPersistence
Projects with existing descriptors are automatically imported with the
IMPORT_AND_MERGE flag.
Re-introduce the previously removed assertion

This reverts commit 5ce6123
Copy link
Member

@oehme oehme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go, just some minor stylistic comments. Please feel free to merge.

/**
* Persists all changes on the disk.
*/
void flush();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be on ModelPersistence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose this because this way we don't have to use instanceof when saving the state in DefaultModelPersistence.

*
* @author Donat Csikos
*/
public abstract class PersistentUpdater {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a helper instead of a base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly, I like the superclass better because it states that from all the existing updaters only the subclasses persist their state.

@donat donat merged commit b566a86 into master Dec 12, 2016
@donat donat deleted the dc-simpler-project-sync branch August 3, 2017 14:49
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.

None yet

2 participants