zDev - M2E - OSS
  1. zDev - M2E - OSS
  2. MNGECLIPSE-474

The "Enable Workspace Resolution" menu item has no function due to typo in code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.0.12
    • Fix Version/s: 0.9.0
    • Component/s: Dependency Resolver
    • Labels:
      None
    • Global Rank:
      15207

      Description

      I've never had any luck with clicking or not clicking the "Enable Workspace Resolution" menu item in the Maven project menu. My preference is to never do workspace resolution and only use artifacts from my local repository. Since it appears the default behavior was to resolve in the workspace I've had a few issues. To try and figure out what the "Enable Workspace Resolution" menu item does I checked out the source could and I think I found a bug.

      In MavenMenuAction there is the following:
      addMenu("org.maven.ide.eclipse.workspaceResolution", "Enable Workspace Resolution", new EnableNatureAction("workspace"), menu);

      The EnableNatureAction has the following code:
      public EnableNatureAction(String option)

      { setInitializationData(null, null, option); }

      public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
      if(Maven2Plugin.INCLUDE_MODULES.equals(data))

      { this.includeModules = true; }

      else if(Maven2Plugin.NO_WORKSPACE_PROJECTS.equals(data))

      { this.workspaceProjects = false; }

      }

      The constant Maven2Plugin.NO_WORKSPACE_PROJECTS is set to "noworkspace"

      So as far as I can tell the EnableNatureAction for the "Enable Workspace Resolution" item is essentially a no-op since nothing is changed. My guess from looking at the code is that the "Enable Workspace Resolution" menu item should read "Disable Workspace Resolution" and the line in MavenMenuAction should be:
      addMenu("org.maven.ide.eclipse.workspaceResolution", "Disable Workspace Resolution", new EnableNatureAction("noworkspace"), menu);

      I'll see if I can figure out how to build a local version of the plugin with this change to provide a patch but I've never done Eclipse plugin development before.

      1. m2e_menu.patch
        6 kB
        Eric Dalquist
      2. m2e_menu.patch
        7 kB
        Eric Dalquist

        Activity

        Hide
        Eric Dalquist added a comment -

        Also, looking in greater detail at the EnableNatureAction it appears that even with fixing this issue there will still be bugs. For example there will be no way to enable module resolution AND disable workspace resolution since you can't change both values that are passed to the ResolverConfiguration when the maven nature is updated via the enableMavenNature call.

        Show
        Eric Dalquist added a comment - Also, looking in greater detail at the EnableNatureAction it appears that even with fixing this issue there will still be bugs. For example there will be no way to enable module resolution AND disable workspace resolution since you can't change both values that are passed to the ResolverConfiguration when the maven nature is updated via the enableMavenNature call.
        Hide
        Eugene Kuleshov added a comment -

        Eric, I am not sure what issue you have with this. Are you trying to do some kind of code review or reporting a bug?

        If it is the latter, please provide the following: exact steps you do, what you see/get after those steps, what you expect to see/get. Thanks.

        Please also note that you can change container configuration on the "Libraries" tab on the "Java Build Path" preferences on your Java project; or directly from popup menu on "Maven Dependencies" container.

        Show
        Eugene Kuleshov added a comment - Eric, I am not sure what issue you have with this. Are you trying to do some kind of code review or reporting a bug? If it is the latter, please provide the following: exact steps you do, what you see/get after those steps, what you expect to see/get. Thanks. Please also note that you can change container configuration on the "Libraries" tab on the "Java Build Path" preferences on your Java project; or directly from popup menu on "Maven Dependencies" container.
        Hide
        Eric Dalquist added a comment -

        It is a bug report. Going through the Libraries tab on the Java Build Path screen shows the configuration screen with a "Resolve Dependencies from Workspace project" checkbox which does exactly what I was looking for. Checking the .classpath file confirms that the 'noworkspace' option is added to the MAVEN2_CLASSPATH_CONTAINER entry.

        Knowing about that config page makes me question the function of the "Enable Workspace Resolution" and "Enable Nested Modules" menu times in the Maven project context menu.

        -Selecting "Enable Workspace Resolution" will always set "Resolve Dependencies from Workspace project" to true and "Include dependencies and source folders from modules" to false.
        -Selecting "Enable Nested Modules" will always set "Resolve Dependencies from Workspace project" to true and "Include dependencies and source folders from modules" to true.

        Perhaps this issue is better characterized as a feature request. It would be good to have these menu items reflect the state of the checkboxes on the Maven 2 Classpath Container config page, changing their text between Enable and Disable and also have them only affect their respective properties. Either that or simply remove both items in preference of the config page.

        Show
        Eric Dalquist added a comment - It is a bug report. Going through the Libraries tab on the Java Build Path screen shows the configuration screen with a "Resolve Dependencies from Workspace project" checkbox which does exactly what I was looking for. Checking the .classpath file confirms that the 'noworkspace' option is added to the MAVEN2_CLASSPATH_CONTAINER entry. Knowing about that config page makes me question the function of the "Enable Workspace Resolution" and "Enable Nested Modules" menu times in the Maven project context menu. -Selecting "Enable Workspace Resolution" will always set "Resolve Dependencies from Workspace project" to true and "Include dependencies and source folders from modules" to false. -Selecting "Enable Nested Modules" will always set "Resolve Dependencies from Workspace project" to true and "Include dependencies and source folders from modules" to true. Perhaps this issue is better characterized as a feature request. It would be good to have these menu items reflect the state of the checkboxes on the Maven 2 Classpath Container config page, changing their text between Enable and Disable and also have them only affect their respective properties. Either that or simply remove both items in preference of the config page.
        Hide
        Eric Dalquist added a comment -

        This patch makes the text on for the "Workspace Resolution" and "Nested Modules" items in the Maven project context menu dynamic based on the current state of those settings. The state of the string in the menu will correspond to the check boxes in the Maven 2 Classpath configuration window and use of each menu item will only change that particular setting and not affect any other setting.

        Show
        Eric Dalquist added a comment - This patch makes the text on for the "Workspace Resolution" and "Nested Modules" items in the Maven project context menu dynamic based on the current state of those settings. The state of the string in the menu will correspond to the check boxes in the Maven 2 Classpath configuration window and use of each menu item will only change that particular setting and not affect any other setting.
        Hide
        Eric Dalquist added a comment -

        The first patch was not correct. It did not toggle between states with the menu items. This patch has been tested and I verified that it does correctly toggle the state of the modules and noworkspace flags.

        Show
        Eric Dalquist added a comment - The first patch was not correct. It did not toggle between states with the menu items. This patch has been tested and I verified that it does correctly toggle the state of the modules and noworkspace flags.
        Hide
        Stefan Seidel added a comment -

        I confirm this is a bug. I never cared about the menu entries in right-click of the project node, but they do always show "Enable ...", even if the option is enabled already.

        Show
        Stefan Seidel added a comment - I confirm this is a bug. I never cared about the menu entries in right-click of the project node, but they do always show "Enable ...", even if the option is enabled already.
        Hide
        Eugene Kuleshov added a comment -

        Thanks for the patch guys. Unfortunately due to the code restructuring we have fixed this issue ourselves. Please feel free to reopen if you experience the same issue with the new build.

        Show
        Eugene Kuleshov added a comment - Thanks for the patch guys. Unfortunately due to the code restructuring we have fixed this issue ourselves. Please feel free to reopen if you experience the same issue with the new build.

          People

          • Assignee:
            Eugene Kuleshov
            Reporter:
            Eric Dalquist
            Last Updated By:
            Brian Fox
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Date of First Response: