[
https://issues.apache.org/jira/browse/IVYDE-234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833026#action_12833026
]
Jeffrey M. Metcalf commented on IVYDE-234:
------------------------------------------
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) {
+ // 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);
> Add branch comparison to workspace resolver
> -------------------------------------------
>
> Key: IVYDE-234
> URL: https://issues.apache.org/jira/browse/IVYDE-234
> Project: IvyDE
> Issue Type: New Feature
> Components: workspace resolver
> Affects Versions: 2.0.0.final
> Reporter: Jeffrey M. Metcalf
> Priority: Minor
> Fix For: 2.1.0
>
> Original Estimate: 48h
> Remaining Estimate: 48h
>
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.