Bug 161287 Patching a plugin causes warnings on features that look bad
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteStatusAnalyzer.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteStatusAnalyzer.java
index a492404..b55ca75 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteStatusAnalyzer.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/core/SiteStatusAnalyzer.java
@@ -109,7 +109,7 @@
// check ambiguous against registry [17015]
IPluginEntry[] featuresEntries = feature.getPluginEntries();
- return status(featuresEntries);
+ return status( feature, featuresEntries);
}
/*
@@ -215,7 +215,7 @@
/*
* compute the status based on getStatus() rules
*/
- private IStatus status(IPluginEntry[] featurePlugins) {
+ private IStatus status(IFeature pluginsOriginatorFeature, IPluginEntry[] featurePlugins) {
VersionedIdentifier featurePluginID;
String happyMSG = Messages.SiteLocal_FeatureHappy;
@@ -241,22 +241,27 @@
// Check if there is another feature with this plugin (but different version)
// log it
bundles = pkgAdmin.getBundles(featurePluginID.getIdentifier(), null);
- for (int j=0; bundles != null && j<bundles.length; j++ ) {
+ for (int j = 0; bundles != null && j < bundles.length && !found; j++ ) {
String bundleVersion = (String)bundles[j].getHeaders().get(Constants.BUNDLE_VERSION);
IFeature feature = getFeatureForId(new VersionedIdentifier(bundles[j].getSymbolicName(), bundleVersion ));
- String msg = null;
- if (feature == null) {
- Object[] values = new Object[] {bundles[j].getSymbolicName(), featurePluginID.getVersion(), bundleVersion};
- msg = NLS.bind(Messages.SiteLocal_TwoVersionSamePlugin1, values);
+ if ((feature != null) && (!isFeaturePatchOfThisFeature(pluginsOriginatorFeature, feature))) {
+ String msg = null;
+ if (feature == null) {
+ Object[] values = new Object[] {bundles[j].getSymbolicName(), featurePluginID.getVersion(), bundleVersion};
+ msg = NLS.bind(Messages.SiteLocal_TwoVersionSamePlugin1, values);
+ } else {
+ String label = feature.getLabel();
+ String featureVersion = feature.getVersionedIdentifier().getVersion().toString();
+ Object[] values = new Object[] { bundles[j].getSymbolicName(), featurePluginID.getVersion(), bundleVersion, label, featureVersion };
+ msg = NLS.bind(Messages.SiteLocal_TwoVersionSamePlugin2, values);
+ }
+
+ UpdateCore.warn("Found another version of the same plugin on the path:" + bundles[j].getSymbolicName() + " " + bundleVersion); //$NON-NLS-1$ //$NON-NLS-2$
+ tempmulti.add(createStatus(IStatus.ERROR, IFeature.STATUS_AMBIGUOUS, msg, null));
} else {
- String label = feature.getLabel();
- String featureVersion = feature.getVersionedIdentifier().getVersion().toString();
- Object[] values = new Object[] { bundles[j].getSymbolicName(), featurePluginID.getVersion(), bundleVersion, label, featureVersion };
- msg = NLS.bind(Messages.SiteLocal_TwoVersionSamePlugin2, values);
+ found = true;
}
-
- UpdateCore.warn("Found another version of the same plugin on the path:" + bundles[j].getSymbolicName() + " " + bundleVersion); //$NON-NLS-1$ //$NON-NLS-2$
- tempmulti.add(createStatus(IStatus.ERROR, IFeature.STATUS_AMBIGUOUS, msg, null));
+
}
@@ -285,6 +290,25 @@
// we return happy as we consider the isBroken verification has been done
return createStatus(IStatus.OK, IFeature.STATUS_HAPPY, happyMSG, null);
}
+ private boolean isFeaturePatchOfThisFeature(IFeature pluginsOriginatorFeature, IFeature feature) {
+
+ if (!feature.isPatch())
+ return false;
+
+ IImport[] featureImports = feature.getImports();
+
+ if (featureImports == null) {
+ return false;
+ }
+
+ for(int i = 0; i < featureImports.length; i++) {
+ if (featureImports[i].isPatch() && featureImports[i].getVersionedIdentifier().equals(pluginsOriginatorFeature.getVersionedIdentifier())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/*
* creates a Status
*/
diff --git a/update/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java b/update/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java
index 819097a..1196201 100644
--- a/update/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java
+++ b/update/org.eclipse.update.core/src/org/eclipse/update/internal/search/SiteSearchCategory.java
@@ -26,6 +26,7 @@
import org.eclipse.update.core.ISiteFeatureReference;
import org.eclipse.update.internal.core.ExtendedSite;
import org.eclipse.update.internal.core.LiteFeature;
+import org.eclipse.update.internal.core.UpdateCore;
import org.eclipse.update.search.IQueryUpdateSiteAdapter;
import org.eclipse.update.search.IUpdateSearchFilter;
import org.eclipse.update.search.IUpdateSearchQuery;
@@ -233,7 +234,7 @@
}
}
} catch (CoreException e) {
- System.out.println(e);
+ UpdateCore.log(e);
} finally {
monitor.worked(1);
}