IvyDE
  1. IvyDE
  2. IVYDE-234

Add branch comparison to workspace resolver

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0.final
    • Fix Version/s: 2.2.0.beta1
    • Component/s: workspace resolver
    • Labels:
      None

      Description

      Currently IvyDE uses the org, module, (and revision by default) when resolving workspace dependencies. I propose adding branch as an optional attribute to be matched in the workspace dependency code. For consistency with the current workspace dependency configuration, I would add an option to ignore branch in the comparison similar to the option for revision. As with revision, the default would be unchecked. This means that the default would be to compare branch attributes when identifying project dependencies, which helps guarantee the correct and most appropriate dependency match. The addition of the branch attribute in the comparison helps in the case where more than one project exists on the same module in the Eclipse workspace and another project defines a latest.status dependency on that module. The current revision comparison code fails to detect the difference between the dependent workspace projects. Therefore by specifying a value for branch in the dependency and module descriptor, a correct match is found.

      1. ivyde-234.patch
        10 kB
        Jeffrey M. Metcalf

        Activity

        Hide
        Nicolas Lalevée added a comment -

        Patch applied, thanks Jeffrey !

        Show
        Nicolas Lalevée added a comment - Patch applied, thanks Jeffrey !
        Hide
        Ben Turner added a comment -

        Reading through this, not sure if it addresses the case I am struggling with. Similar deal, where code on trunk or a release branch is marked as "latest.integration". However, I have a different workspace per branch, so avoid the problems you were having. The problem I have is on trunk, the replacement's work. But on trunk, it doesn't identify the modules as related and does no substitution.

        I had also noted we don't publish our artifacts with a "branch" tag - we use version number alone to lock down dependencies (e.g. 17.0-+ or HEAD-+). This might also be required I guess.

        Show
        Ben Turner added a comment - Reading through this, not sure if it addresses the case I am struggling with. Similar deal, where code on trunk or a release branch is marked as "latest.integration". However, I have a different workspace per branch, so avoid the problems you were having. The problem I have is on trunk, the replacement's work. But on trunk, it doesn't identify the modules as related and does no substitution. I had also noted we don't publish our artifacts with a "branch" tag - we use version number alone to lock down dependencies (e.g. 17.0-+ or HEAD-+). This might also be required I guess.
        Hide
        Jeffrey M. Metcalf added a comment -

        Looks like the text paste of the patch had issues. I have attached the patch against revision 908337 as a file.

        Show
        Jeffrey M. Metcalf added a comment - Looks like the text paste of the patch had issues. I have attached the patch against revision 908337 as a file.
        Hide
        Jeffrey M. Metcalf added a comment -

        Here is my patch against revision 908337 for this issue.

        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java (working copy)
        @@ -34,6 +34,7 @@
        import org.apache.ivy.core.module.descriptor.ExcludeRule;
        import org.apache.ivy.core.module.descriptor.License;
        import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
        +import org.apache.ivy.core.module.id.ModuleId;
        import org.apache.ivy.core.module.id.ModuleRevisionId;
        import org.apache.ivy.core.report.ArtifactDownloadReport;
        import org.apache.ivy.core.report.DownloadReport;
        @@ -106,6 +107,8 @@

        private IJavaProject[] projects;

        + private boolean ignoreBranchOnWorkspaceProjects;
        +
        private boolean ignoreVersionOnWorkspaceProjects;

        public WorkspaceResolver(IJavaProject javaProject, IvySettings ivySettings)

        { @@ -121,6 +124,9 @@ + resolvingJavaProject.getElementName(), e); }

        + ignoreBranchOnWorkspaceProjects = IvyPlugin.getPreferenceStoreHelper()
        + .getIgnoreBranchOnWorkspaceProjects();
        +
        ignoreVersionOnWorkspaceProjects = IvyPlugin.getPreferenceStoreHelper()
        .getIgnoreVersionOnWorkspaceProjects();
        }
        @@ -179,10 +185,36 @@
        continue;
        }

        • if (!md.getModuleRevisionId().getModuleId().equals(dependencyMrid.getModuleId())) {
          + ModuleRevisionId candidateMrid = md.getModuleRevisionId();
          +
          + if (!candidateMrid.getModuleId().equals(dependencyMrid.getModuleId())) { // it doesn't match org#module continue; }

          +
          + if (!ignoreBranchOnWorkspaceProjects) {
          + ModuleId mid = dependencyMrid.getModuleId();
          + String defaultBranch = getSettings().getDefaultBranch(mid);
          + String dependencyBranch = dependencyMrid.getBranch();
          + String candidateBranch = candidateMrid.getBranch();
          + if (dependencyBranch == null)

          { + dependencyBranch = defaultBranch; + }

          + if (candidateBranch == null)

          { + candidateBranch = defaultBranch; + }

          + if (dependencyBranch != candidateBranch)

          Unknown macro: {+ // Both cannot be null+ if (dependencyBranch == null || candidateBranch == null) { + // One set, the other isn't, so no match + continue; + }+ if (!dependencyBranch.equals(candidateBranch)) { + // Both set but to different branches, so no match + continue; + }+ }

          + }

        // Found one; check if it is for the module we need
        if (ignoreVersionOnWorkspaceProjects
        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (working copy)
        @@ -108,11 +108,13 @@

        event.getProperty() == PreferenceConstants.SOURCES_SUFFIXES
        event.getProperty() == PreferenceConstants.JAVADOC_SUFFIXES
        event.getProperty() == PreferenceConstants.DO_RETRIEVE_DEPRECATED
        event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN_DEPRECATED
        +
        event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN_DEPRECATED
        event.getProperty() == PreferenceConstants.DO_RETRIEVE
        event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN
        event.getProperty() == PreferenceConstants.RETRIEVE_SYNC
        event.getProperty() == PreferenceConstants.ALPHABETICAL_ORDER
        +
        event.getProperty() == PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS
        +
        event.getProperty() == PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS
        event.getProperty() == PreferenceConstants.RESOLVE_IN_WORKSPACE) { prefStoreChanged(); }

        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (working copy)
        @@ -110,7 +110,9 @@
        public static final boolean DEFAULT_AUTO_RESOLVE_ON_OPEN = false;

        public static final boolean DEFAULT_AUTO_RESOLVE_ON_CHANGE = true;

        • +
          + public static final boolean DEFAULT_IGNORE_BRANCH_ON_WORKSPACE_PROJECTS = false;
          +
          public static final boolean DEFAULT_IGNORE_VERSION_ON_WORKSPACE_PROJECTS = false;

        public void initializeDefaultPreferences()

        { @@ -165,6 +167,9 @@ store.setDefault(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, DEFAULT_IVY_CONSOLE_LOG_MESSAGE); + store.setDefault(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS, + DEFAULT_IGNORE_BRANCH_ON_WORKSPACE_PROJECTS); + store.setDefault(PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS, DEFAULT_IGNORE_VERSION_ON_WORKSPACE_PROJECTS); }

        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (working copy)
        @@ -82,6 +82,9 @@

        public static final String IVY_CONSOLE_LOG_LEVEL = "ivyConsole.logLevel";

        + public static final String IGNORE_BRANCH_ON_WORKSPACE_PROJECTS
        + = "workspaceResolver.ignoreBranch";
        +
        public static final String IGNORE_VERSION_ON_WORKSPACE_PROJECTS
        = "workspaceResolver.ignoreVersion";
        }
        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (working copy)
        @@ -191,6 +191,15 @@
        prefStore.setValue(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, logLevel);
        }

        + public boolean getIgnoreBranchOnWorkspaceProjects()

        { + return prefStore.getBoolean(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS); + }

        +
        + public void setIgnoreBranchOnWorkspaceProjects(boolean ignoreBranchOnWorkspaceProjects)

        { + prefStore.setValue(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS, + ignoreBranchOnWorkspaceProjects); + }

        +
        public boolean getIgnoreVersionOnWorkspaceProjects()

        { return prefStore.getBoolean(PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS); }

        Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java
        ===================================================================
        — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java (revision 908337)
        +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java (working copy)
        @@ -69,7 +69,20 @@
        }
        };
        addField(autoResolveOnOpen);
        +
        + BooleanFieldEditor ignoreBranchOnWorkspaceProjects = new BooleanFieldEditor(
        + PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS,
        + "Ignore branch when resolving workspace projects", fieldParent) {
        + protected Label getLabelControl()

        { + Label label = super.getLabelControl(); + label.setToolTipText("Will ignore the artifact branch when resolving " + + "against workspace projects"); + return label; + }

        + };

        + addField(ignoreBranchOnWorkspaceProjects);
        +
        BooleanFieldEditor ignoreVersionOnWorkspaceProjects = new BooleanFieldEditor(
        PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS,
        "Ignore version when resolving workspace projects", fieldParent) {
        @@ -84,9 +97,10 @@
        addField(ignoreVersionOnWorkspaceProjects);

        Label warning = new Label(fieldParent, SWT.NONE);

        • warning.setText("WARNING: you should use this only if you are sure the projets opened\n"
        • + "in your workspace can actually work with each other, be carefull with\n"
        • + "branch management for instance)");
          + warning.setText("WARNING: you should ignore branch and/or revision only\n" +
          + "if you are sure that all the project revisions that are\n" +
          + "open in your workspace can actually work together\n" +
          + "(be careful with branch management for instance)");
          GridData gridData = new GridData();
          gridData.horizontalIndent = HORIZ_INDENT;
          warning.setLayoutData(gridData);
        Show
        Jeffrey M. Metcalf added a comment - Here is my patch against revision 908337 for this issue. Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/workspaceresolver/WorkspaceResolver.java (working copy) @@ -34,6 +34,7 @@ import org.apache.ivy.core.module.descriptor.ExcludeRule; import org.apache.ivy.core.module.descriptor.License; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; +import org.apache.ivy.core.module.id.ModuleId; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.ArtifactDownloadReport; import org.apache.ivy.core.report.DownloadReport; @@ -106,6 +107,8 @@ private IJavaProject[] projects; + private boolean ignoreBranchOnWorkspaceProjects; + private boolean ignoreVersionOnWorkspaceProjects; public WorkspaceResolver(IJavaProject javaProject, IvySettings ivySettings) { @@ -121,6 +124,9 @@ + resolvingJavaProject.getElementName(), e); } + ignoreBranchOnWorkspaceProjects = IvyPlugin.getPreferenceStoreHelper() + .getIgnoreBranchOnWorkspaceProjects(); + ignoreVersionOnWorkspaceProjects = IvyPlugin.getPreferenceStoreHelper() .getIgnoreVersionOnWorkspaceProjects(); } @@ -179,10 +185,36 @@ continue; } if (!md.getModuleRevisionId().getModuleId().equals(dependencyMrid.getModuleId())) { + ModuleRevisionId candidateMrid = md.getModuleRevisionId(); + + if (!candidateMrid.getModuleId().equals(dependencyMrid.getModuleId())) { // it doesn't match org#module continue; } + + if (!ignoreBranchOnWorkspaceProjects) { + ModuleId mid = dependencyMrid.getModuleId(); + String defaultBranch = getSettings().getDefaultBranch(mid); + String dependencyBranch = dependencyMrid.getBranch(); + String candidateBranch = candidateMrid.getBranch(); + if (dependencyBranch == null) { + dependencyBranch = defaultBranch; + } + if (candidateBranch == null) { + candidateBranch = defaultBranch; + } + if (dependencyBranch != candidateBranch) Unknown macro: {+ // Both cannot be null+ if (dependencyBranch == null || candidateBranch == null) { + // One set, the other isn't, so no match + continue; + }+ if (!dependencyBranch.equals(candidateBranch)) { + // Both set but to different branches, so no match + continue; + }+ } + } // Found one; check if it is for the module we need if (ignoreVersionOnWorkspaceProjects Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyPlugin.java (working copy) @@ -108,11 +108,13 @@ event.getProperty() == PreferenceConstants.SOURCES_SUFFIXES event.getProperty() == PreferenceConstants.JAVADOC_SUFFIXES event.getProperty() == PreferenceConstants.DO_RETRIEVE_DEPRECATED event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN_DEPRECATED + event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN_DEPRECATED event.getProperty() == PreferenceConstants.DO_RETRIEVE event.getProperty() == PreferenceConstants.RETRIEVE_PATTERN event.getProperty() == PreferenceConstants.RETRIEVE_SYNC event.getProperty() == PreferenceConstants.ALPHABETICAL_ORDER + event.getProperty() == PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS + event.getProperty() == PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS event.getProperty() == PreferenceConstants.RESOLVE_IN_WORKSPACE) { prefStoreChanged(); } Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (working copy) @@ -110,7 +110,9 @@ public static final boolean DEFAULT_AUTO_RESOLVE_ON_OPEN = false; public static final boolean DEFAULT_AUTO_RESOLVE_ON_CHANGE = true; + + public static final boolean DEFAULT_IGNORE_BRANCH_ON_WORKSPACE_PROJECTS = false; + public static final boolean DEFAULT_IGNORE_VERSION_ON_WORKSPACE_PROJECTS = false; public void initializeDefaultPreferences() { @@ -165,6 +167,9 @@ store.setDefault(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, DEFAULT_IVY_CONSOLE_LOG_MESSAGE); + store.setDefault(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS, + DEFAULT_IGNORE_BRANCH_ON_WORKSPACE_PROJECTS); + store.setDefault(PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS, DEFAULT_IGNORE_VERSION_ON_WORKSPACE_PROJECTS); } Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (working copy) @@ -82,6 +82,9 @@ public static final String IVY_CONSOLE_LOG_LEVEL = "ivyConsole.logLevel"; + public static final String IGNORE_BRANCH_ON_WORKSPACE_PROJECTS + = "workspaceResolver.ignoreBranch"; + public static final String IGNORE_VERSION_ON_WORKSPACE_PROJECTS = "workspaceResolver.ignoreVersion"; } Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (working copy) @@ -191,6 +191,15 @@ prefStore.setValue(PreferenceConstants.IVY_CONSOLE_LOG_LEVEL, logLevel); } + public boolean getIgnoreBranchOnWorkspaceProjects() { + return prefStore.getBoolean(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS); + } + + public void setIgnoreBranchOnWorkspaceProjects(boolean ignoreBranchOnWorkspaceProjects) { + prefStore.setValue(PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS, + ignoreBranchOnWorkspaceProjects); + } + public boolean getIgnoreVersionOnWorkspaceProjects() { return prefStore.getBoolean(PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS); } Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java =================================================================== — org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java (revision 908337) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/WorkspaceResolverPreferencePage.java (working copy) @@ -69,7 +69,20 @@ } }; addField(autoResolveOnOpen); + + BooleanFieldEditor ignoreBranchOnWorkspaceProjects = new BooleanFieldEditor( + PreferenceConstants.IGNORE_BRANCH_ON_WORKSPACE_PROJECTS, + "Ignore branch when resolving workspace projects", fieldParent) { + protected Label getLabelControl() { + Label label = super.getLabelControl(); + label.setToolTipText("Will ignore the artifact branch when resolving " + + "against workspace projects"); + return label; + } + }; + addField(ignoreBranchOnWorkspaceProjects); + BooleanFieldEditor ignoreVersionOnWorkspaceProjects = new BooleanFieldEditor( PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS, "Ignore version when resolving workspace projects", fieldParent) { @@ -84,9 +97,10 @@ addField(ignoreVersionOnWorkspaceProjects); Label warning = new Label(fieldParent, SWT.NONE); warning.setText("WARNING: you should use this only if you are sure the projets opened\n" + "in your workspace can actually work with each other, be carefull with\n" + "branch management for instance)"); + warning.setText("WARNING: you should ignore branch and/or revision only\n" + + "if you are sure that all the project revisions that are\n" + + "open in your workspace can actually work together\n" + + "(be careful with branch management for instance)"); GridData gridData = new GridData(); gridData.horizontalIndent = HORIZ_INDENT; warning.setLayoutData(gridData);

          People

          • Assignee:
            Nicolas Lalevée
            Reporter:
            Jeffrey M. Metcalf
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 48h
              48h
              Remaining:
              Remaining Estimate - 48h
              48h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development