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

Add pub support #107

Merged
merged 19 commits into from Jul 31, 2019

Conversation

@jonas-jonas
Copy link
Member

commented Jul 21, 2019

  • Automatic synchronization of pub depencies (using pub get) for any project.
    -Can be disabled via the Preference page
  • A command in the project context menus for Dart projects to sync the dependencies (also via pub get) manually
  • Preference to use the --offline flag for all pub get operations (to use locally cached packages for package resolution)
WIP Adds pub support
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 21, 2019

Hi @lak-proddev,

I tinkered around with a workspace listener to listen on changes to "pubspec.yaml" files. It is quite tedious and I'm not sure if this is the correct way to do this. Could you review and test? Thanks.

@lak-proddev

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

Hi @lak-proddev,

I tinkered around with a workspace listener to listen on changes to "pubspec.yaml" files. It is quite tedious and I'm not sure if this is the correct way to do this. Could you review and test? Thanks.

As per @vogella comment, We need to use startup OSGi service to register the resource listener.
I think this is what he meant for
https://wiki.eclipse.org/Eclipse4/RCP/Lifecycle

    @PostContextCreate
    public void startup(IEclipseContext context) {
       // do initialization 
    }

I also looking same solution for registring the logger

- using e4 model
Signed-off-by: Lakshminarayana Nekkanti <narayana.nekkanti@gmail.com>
@lak-proddev

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

@jonas-jonas I pushed mistakenly. Please, check whether it's working for you as expected.

Revert "- using e4 model"
This reverts commit 50ff97c.
@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 22, 2019

@jonas-jonas I pushed mistakenly. Please, check whether it's working for you as expected.

No problem at all. For me it seems to work with your commit before the revert. Why did you revert?

Also do feel free to push onto branches of mine, if you feel it's needed to improve the code. No need to communicate code changes solely through comments. :)

@vogella

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

@lak-proddev

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

Jonas, Yes it will work. But, need to improve a bit. With my commit, the listener will add for every event (multiple times).
So, need to find the correct event.

@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 22, 2019

IIRC the annotation provides a way to enable it eagerly. Jonas, please have
a look and add this to the tutorial.
You can use the OSGi console to see if it is running

@vogella, @lak-proddev didn't use an annotation for the service. It is registered via the org.eclipse.dartboard.workbench.model.WorkbenchModelProcessor extension point.
In there a subscription to the APP_STARTUP_COMPLETE event is done. And in there the Listener is added to the workspace. As this should only be fired once (on App startup), I don't see a problem there @lak-proddev. But I'm probably missing something here.

Use OSGI service instead of StartupListener
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@jonas-jonas
Copy link
Member Author

left a comment

I used an OSGI service here instead of the StartupListener. I'm not sure if I've done this correctly. Could someone verify?

@vogella

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

jonas-jonas added 5 commits Jul 22, 2019
Merge branch master into pub
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Add support for --offline and use NLS for messages
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Merge branch master
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Add "get dependencies" handler and command
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 24, 2019

This PR adds multiple things related to the Pub package manager.
Pub is distributed with any Dart SDK (in the bin/ directory).

Features added by the PR:

  • Automatic synchronization of pub depencies (using pub get) for any project.
    • Can be disabled via the Preference page
  • A command in the project context menus for Dart projects to sync the dependencies (also via pub get) manually
  • Preference to use the --offline flag for all pub get operations (to use locally cached packages for package resolution)

I tested it on my windows VM and it worked for me. Please do test on your machine.

Also I'd like to provide PubServer as an @Injectable service but it doesn't seem to work with AbstractHandlers with the org.eclipse.ui.handlers extension point. Is this even possible?

@jonas-jonas jonas-jonas requested a review from lak-proddev Jul 24, 2019

jonas-jonas added 2 commits Jul 25, 2019
Add explanatory comment to PUBSPEC constant
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Refine check for visibility of Pub popup menu entry
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>

@jonas-jonas jonas-jonas removed the request for review from lak-proddev Jul 29, 2019

jonas-jonas added 2 commits Jul 29, 2019
Add PUB_ENVIROMENT variable to the pub get call
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Add PubUtil
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@Activate
public void registerListeners() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(new PubspecChangeListener());

This comment has been minimized.

Copy link
@lak-proddev

lak-proddev Jul 30, 2019

Contributor

Don't we need to remove the listener?. I am not sure.

This comment has been minimized.

Copy link
@jonas-jonas

jonas-jonas Jul 30, 2019

Author Member

Yes, ideally we would remove the listener when the user unchecks the checkbox on the preference page. But as the ListenerService is not available in the class in the current design, the listener stays registered as is and the necessary checks are done whenever it fires.

And it should stay registered until the workspace is closed.

* A {@link Map} holding an {@link IProject} and a {@link Job} as ideally there
* should only be one {@code pub get} job running per project.
*/
private Map<IProject, Job> pubGetJobs = new HashMap<>();

This comment has been minimized.

Copy link
@lak-proddev

lak-proddev Jul 30, 2019

Contributor

I am not sure about the flow of this class. Can you check do we need to clear or making null.

This comment has been minimized.

Copy link
@jonas-jonas

jonas-jonas Jul 30, 2019

Author Member

I am not sure about the flow of this class. Can you check do we need to clear or making null.

I'm not sure what you mean by this. The Map should always be the same object for the lifetime of the object.

jonas-jonas added 2 commits Jul 30, 2019
Fix comments
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Remove obsolete object reference
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 30, 2019

Alright, I think I tested the functionality of this patch thoroughly on Windows and Linux.

As mentioned in the comments above, most of the service architecture depends on a working structure of OSGi services, which is out of scope of this patch. I will ask @vogella once he is back in office to see what we can do about it.

I'd like to merge and see what happens. Any objections?

@lak-proddev

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2019

No objections from my side.

@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 30, 2019

And I would merge if there wasn't an exception on every startup related to the OSGi service:

If the plugin is installed from an update site, after a second restart after the install the IDE fails to start with the following exception in the log. It does not happen if I remove the ListenerService.

Anyone know a solution to this? If not, the startup extension would be the other solution, we could use.

Root exception:
java.lang.IllegalStateException: The instance data location has not been specified yet.
	at org.eclipse.core.internal.runtime.DataArea.assertLocationInitialized(DataArea.java:59)
	at org.eclipse.core.internal.runtime.DataArea.getStateLocation(DataArea.java:136)
	at org.eclipse.core.internal.runtime.InternalPlatform.getStateLocation(InternalPlatform.java:545)
	at org.eclipse.core.runtime.Plugin.getStateLocation(Plugin.java:259)
	at org.eclipse.core.internal.resources.LocalMetaArea.<init>(LocalMetaArea.java:63)
	at org.eclipse.core.resources.ResourcesPlugin.start(ResourcesPlugin.java:481)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:842)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:834)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:791)
	at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1013)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:365)
	at org.eclipse.osgi.container.Module.doStart(Module.java:598)
	at org.eclipse.osgi.container.Module.start(Module.java:462)
	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:493)
	at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:117)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:570)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:330)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:396)
	at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:41)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:470)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:423)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:415)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:155)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructors(Class.java:1651)
	at org.apache.felix.scr.impl.inject.ComponentConstructor.<init>(ComponentConstructor.java:94)
	at org.apache.felix.scr.impl.inject.ComponentMethodsImpl.initComponentMethods(ComponentMethodsImpl.java:106)
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.initDependencyManagers(AbstractComponentManager.java:1008)
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.collectDependencies(AbstractComponentManager.java:1026)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:936)
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:765)
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:666)
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:432)
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665)
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:381)
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49)
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:263)
	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196)
	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169)
	at org.apache.felix.scr.impl.AbstractExtender.addingBundle(AbstractExtender.java:139)
	at org.apache.felix.scr.impl.AbstractExtender.addingBundle(AbstractExtender.java:49)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:973)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:234)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:140)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:132)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:231)
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:493)
	at org.eclipse.osgi.container.Module.start(Module.java:480)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$1.run(ModuleContainer.java:1820)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$2$1.execute(EquinoxContainerAdaptor.java:150)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1813)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1769)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1735)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1661)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
@vogella

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2019

Remove osgi services
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
@jonas-jonas

This comment has been minimized.

Copy link
Member Author

commented Jul 31, 2019

After trying virtually every approach I could find, with non of them working without any issues, I reverted back to the startup extension that works without issues out of the box.

As mentioned in previous comments, I'd like to use OSGi services later on for all sorts of services, but couldn't figure out how to use them everywhere. @vogella when you're back we should try to sort this out.

For now, I'm going to merge this patch because I'd like to move forward with featuers. We can refactor it later to conform to OSGi services.

jonas-jonas added 3 commits Jul 31, 2019
Further removals of OSGi related stuff
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
autorefactor
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>
Add missing line to end of ListenerService file
Signed-off-by: Jonas Hungershausen <jonas.hungershausen@vogella.com>

@jonas-jonas jonas-jonas changed the title WIP Add pub support Add pub support Jul 31, 2019

@jonas-jonas jonas-jonas merged commit f8696b7 into master Jul 31, 2019

2 checks passed

default Build finished.
Details
eclipsefdn/eca The author(s) of the pull request is covered by necessary legal agreements in order to proceed!
Details
This was referenced Jul 31, 2019

@jonas-jonas jonas-jonas deleted the pub branch Aug 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.