Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 159135

Summary: Automatic resolution of links between projects and issue repositories
Product: z_Archived Reporter: Eugene Kuleshov <ekuleshov>
Component: MylynAssignee: Eugene Kuleshov <ekuleshov>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P4 CC: wmitsuda
Version: unspecifiedKeywords: helpwanted, plan
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 169788    
Attachments:
Description Flags
implementation of new extension point
none
mylar/context/zip
none
updated patch none

Description Eugene Kuleshov CLA 2006-09-28 12:14:43 EDT
Newly added mechanism for manually configuring links between projects and issue repositories is good when there is no other metadata information around.

However for projects using Maven or Subversion already have such metainfo. In case of Maven it is located in pom.xml and Subversion has special resource property for that.

So, it would make sense to allow to plug in custom repository resolvers that could be contributed by external plugins. I.e. Maven plugin and Mylar's own integration layer for Subclipse. So, instead of hardcoded implementation in TasksUiPlugin.getRepositoryForResource() Mylar should use an extension point and move this implementation into the default contributed resolver. Then TasksUiPlugin.getRepositoryForResource() method would iterate through resolvers and return first non-null repository (if any).

Extension point should also have reference for optional UI panel that 3rd party resolvers could contribute. If not specified, it could just show read-only page with resolved repository, or if it can't be resolved, fall back into the manual resolution and show current UI. Extension point would have the following prefs:

-- name
-- description
-- class

and the implementation API should have following methods:

  TaskRepository resolveRepository(IResource resource)
  boolean hasRepository(IResource resource)  // e.g. return false if it is not a Maven project or don't use Subversion
  XXX getConfigurationPanel();  // return null or panel for configuring mappings

It would make sense to add some UI to allow to choose ordering of contributed resolvers that should allow to enable/disable registered resolvers and change their ordering (you can borrow the UI from patch I contributed for platform hyperlink detectors).
Comment 1 Eugene Kuleshov CLA 2006-09-28 12:19:45 EDT
BTW, it brings up an interesting issue. With this, we may need to allow to implicitly register repositories when projects with enabled repository resolution are added into workspace and unregister those repositories when these projects removed, closed or will change repository mapping (e.g. disconnect Subversion project)...
Comment 2 Mik Kersten CLA 2006-10-02 13:50:14 EDT
This is sounding good, I'll look into it next week.
Comment 3 Mik Kersten CLA 2006-10-16 12:19:40 EDT
The challenge here is that there is a tension between the way that Eclipse stores project preferences (.project, .settings) and in the way that other tools such as Maven store settings (e.g. pom.xml).  The problem is not particular to Mylar, and we had the identical problem with the AspectJ IDE Framework needing to support Eclipse, JBuilder, NetBeans, and Ant, all of which had their own formats.

Assuming that it's too hard to get an extensible project properties mechanism into Platform, I'm wondering if a good way to handle such cases is for something like the Maven Eclipse plug-in to transparently synchronize the settings between the Eclipse preference store and the pom.xml?  The from the users' point of view the Eclipse settings would 'drive' the pom.xml settings, which would provide consistency.  Thoughts?
Comment 4 Eugene Kuleshov CLA 2006-10-16 13:05:45 EDT
Mik, synchronization of the properties won't work. Simply because there would be two places and when both of them changed you would have to do the manual merge. So, there must be not more then one source of such settings.

I don't see this as a very big deal, because you could allow pluggable persistence layer and let 3rd party plugins to provide their own strategy how these settings should be stored.
Comment 5 Mik Kersten CLA 2006-11-11 18:08:43 EST
Can't prioritize this for 1.0, but can help with patches if this is contributed contributed.
Comment 6 Eugene Kuleshov CLA 2007-01-16 14:29:55 EST
In addition to manual repository assignment we have two additional strategies:

-- using JIRA properties. Mark Phippard gave good overview of this in his blog at http://markphip.blogspot.com/2007/01/integrating-subversion-with-your-issue.html

-- using Maven model

So, we should probably add something like priority to the extension point I suggested in the task description. It also seems like we don't need custom panel, but instead should have some way to communicate if that information is editable or not.
Comment 7 Mik Kersten CLA 2007-01-20 19:58:53 EST
How about if the UI on the Task Repository page of Project Properties has two radio choices, the selection of one causing the other section to be grayed out.  This puts all the control in the users hands.

------------------------------------------------
[x] Use settings from project configuration
     [text box with path to file, e.g. com.foo/pom.xml]
------------------------------------------------
[ ] Manually associate repository
     [x] Eclipse Bugzilla
     [ ] Edgewall Trac
     
Eugene: are you or someone else from Maven interested in contributing this?  
Comment 8 Eugene Kuleshov CLA 2007-01-20 20:12:44 EST
I thing it should be much simpler and the idea is to avoid manual configuration if possible. 

So, we can just have priority value to came from the extension point (can be configurable from global properties). Then project properties ui would still show mapped project, but may also disable the editing if extension point contributor prohibits editing.

Then Mylar can just iterate trough contributed extensions in proper order. I.e. JIRA, Maven, Manual.

I can try to shape up this for Subclipse and Maven plugins if you are okay with the approach.
Comment 9 Mik Kersten CLA 2007-01-23 15:56:28 EST
The final control needs to be in the user's hands, not in the extension points.  When tools think they know better than users, some users invariably end up frustrated.  So I'm happy with the approach the you propose, just don't allow the extension point to disallow editing.
Comment 10 Eugene Kuleshov CLA 2007-01-23 16:17:19 EST
(In reply to comment #9)
> The final control needs to be in the user's hands, not in the extension points.
>  When tools think they know better than users, some users invariably end up
> frustrated.  So I'm happy with the approach the you propose, just don't allow
> the extension point to disallow editing.

It will be in the user hands. For Maven they will need to edit Maven's pom.xml and for JIRA - set issue tracking property. I am not sure if we can use Mylar's UI to make these changes and that is why I am suggesting to disable UI for manual editing if extension point has its own information.

We can have an "overwrite" option that would fall back to the manual editing (if you insist), but I think that defaults still should be controlled by the extension points. 

This is somehow similar how code completion is handled in the Java editor. Maybe we can provide global settings to allow user to enable/disable these extension points or change their order, but I think it is an overkill.
Comment 11 Mik Kersten CLA 2007-01-25 15:53:45 EST
OK, let's go for what you suggest, and then if in the final implementation the lack of control on the UI level seems problematic we can address it then.
Comment 12 Eugene Kuleshov CLA 2007-02-20 16:52:49 EST
Created attachment 59419 [details]
implementation of new extension point

Current code for manual repository linking is movedin to DefaultTaskRepositoryLinkProvider which is registered as a default extension point.

    <extension
          point="org.eclipse.mylar.tasks.ui.repositoryLinkProviders">
       <linkProvider
             class="org.eclipse.mylar.tasks.ui.DefaultTaskRepositoryLinkProvider"
             name="Default Repository Link"
             order="1000"
             id="org.eclipse.mylar.tasks.ui.defaultRepositoryLinkProvider">
       </linkProvider>
    </extension>

Provider implementation for Subclipse look like this and it is registered with order 100. So, editing is disabled in the Task Repository page if provider has link and does not allow to change it (technically it could, but it might be confusing because it will require commit to the version control, so I amy look at that later).

public class SubclipseTaskRepositoryLinkProvider extends
    AbstractTaskRepositoryLinkProvider {

  public TaskRepository getTaskRepository(IResource resource,
      TaskRepositoryManager repositoryManager) {
    try {
      ProjectProperties props = ProjectProperties.getProjectProperties(resource);
      return SubclipseTeamPlugin.getRepository(props.getUrl(), repositoryManager);
    } catch (SVNException ex) {
      // ignore
    }
    return null;
  }

}

Provider for Maven will be abot that simple too.
Comment 13 Eugene Kuleshov CLA 2007-02-20 16:52:51 EST
Created attachment 59420 [details]
mylar/context/zip
Comment 14 Mik Kersten CLA 2007-02-20 18:41:11 EST
"Provider" can be a redundant name so I try to avoid it if there is another name that's clear enough, but I can't think of anything better.  However, I think that the name should say that the thing being linked is the project, because the repository aspect seems implicit from the fact that it's tasks.ui.  What do you think of:

    <extension
          point="org.eclipse.mylar.tasks.ui.projectLinkProviders">
       <linkProvider
             class="org.eclipse.mylar.tasks.ui.ProjectPreferencesLinkProvider"/>
    </extension>
    
Side note: at some point I might move this and other org.eclipse.core.resources coupling out of ..mylar.tasks.ui because they prevents the Task List from being reused in a pure RCP app.
Comment 15 Eugene Kuleshov CLA 2007-02-20 18:50:47 EST
(In reply to comment #14)
> "Provider" can be a redundant name so I try to avoid it if there is another
> name that's clear enough, but I can't think of anything better.  However, I
> think that the name should say that the thing being linked is the project,
> because the repository aspect seems implicit from the fact that it's tasks.ui. 
> What do you think of:
> 
>     <extension
>           point="org.eclipse.mylar.tasks.ui.projectLinkProviders">
>        <linkProvider
>             
> class="org.eclipse.mylar.tasks.ui.ProjectPreferencesLinkProvider"/>
>     </extension>

That is ok with me. Either way it is little confusing (link is currently one way from the project/resource to the repository). 

So, will you rename those yourself?
Comment 16 Mik Kersten CLA 2007-02-20 20:11:32 EST
Patch looks good.  Please do the rename and I'll apply.  In the future please do consider adding a unit test for this kind of functionality, at least to make sure that the default provider was initialized and has some default behavior.
Comment 17 Eugene Kuleshov CLA 2007-02-20 20:44:44 EST
Created attachment 59443 [details]
updated patch
Comment 18 Mik Kersten CLA 2007-02-20 20:59:19 EST
Patch applied.
Comment 19 Eugene Kuleshov CLA 2007-02-20 23:38:15 EST
(In reply to comment #18)
> Patch applied.

Thanks a lot Mik. Can you please put new dev build? So, I could commit changes to Subclipse and Maven.

Now I am thinking how we can reuse this info for creating new/missing repositories that are not added in Mylar yet.
Comment 21 Mik Kersten CLA 2007-02-21 13:24:04 EST
Good stuff.  Dev build uploaded.  Regarding automatic creation consider commenting on bug 159135.
Comment 22 Eugene Kuleshov CLA 2007-02-21 15:47:11 EST
(In reply to comment #21)
> Good stuff.  Dev build uploaded.  Regarding automatic creation consider
> commenting on bug 159135.

Umm. Which bug?
Comment 23 Mik Kersten CLA 2007-02-21 18:17:08 EST
Sorry, bug 174864.