Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-23 09:23:11 +0000
committerEike Stepper2012-07-23 09:23:11 +0000
commit21dc1749a52374ab69843928e3aaf8336a981750 (patch)
tree1bc3ebc59e313b08f32344a901e896826c607231 /plugins
parent66e5ff9d1e03bb5d0489042e3a3f46a190998a94 (diff)
downloadcdo-21dc1749a52374ab69843928e3aaf8336a981750.tar.gz
cdo-21dc1749a52374ab69843928e3aaf8336a981750.tar.xz
cdo-21dc1749a52374ab69843928e3aaf8336a981750.zip
Consider feature content closures
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version.digest.ui/src/org/eclipse/emf/cdo/releng/version/digest/ui/CreateDigestAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Release.java72
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/ReleaseManager.java87
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionBuilder.java168
4 files changed, 228 insertions, 102 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.version.digest.ui/src/org/eclipse/emf/cdo/releng/version/digest/ui/CreateDigestAction.java b/plugins/org.eclipse.emf.cdo.releng.version.digest.ui/src/org/eclipse/emf/cdo/releng/version/digest/ui/CreateDigestAction.java
index cb11376111..5cd888e887 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version.digest.ui/src/org/eclipse/emf/cdo/releng/version/digest/ui/CreateDigestAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version.digest.ui/src/org/eclipse/emf/cdo/releng/version/digest/ui/CreateDigestAction.java
@@ -142,7 +142,7 @@ public class CreateDigestAction implements IObjectActionDelegate
continue;
}
- IModel componentModel = VersionBuilder.getComponentModel(element);
+ IModel componentModel = ReleaseManager.INSTANCE.getComponentModel(element);
if (componentModel == null)
{
warnings.add(name + ": Component not found");
@@ -157,7 +157,6 @@ public class CreateDigestAction implements IObjectActionDelegate
}
Version version = VersionBuilder.getComponentVersion(componentModel);
- version = new Version(version.getMajor(), version.getMinor(), version.getMicro());
if (!element.getVersion().equals(version))
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Release.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Release.java
index 77fea92ee3..5e267d2c6d 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Release.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/Release.java
@@ -16,6 +16,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.pde.core.IModel;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
@@ -188,7 +189,7 @@ public class Release
builder.append(indent + "<" + tag + " " + TYPE_ATTRIBUTE + "=\"" + type + "\" " + NAME_ATTRIBUTE + "=\"" + name
+ "\" " + VERSION_ATTRIBUTE + "=\"" + version + "\"");
- List<Element> content = element.getContent();
+ List<Element> content = element.getChildren();
if (content.isEmpty())
{
builder.append("/");
@@ -229,7 +230,9 @@ public class Release
private Version version;
- private List<Element> content = new ArrayList<Element>();
+ private List<Element> children = new ArrayList<Element>();
+
+ private List<Element> allChildren;
public Element(Type type, String name, Version version)
{
@@ -259,9 +262,44 @@ public class Release
return version;
}
- public List<Element> getContent()
+ public List<Element> getChildren()
{
- return content;
+ return children;
+ }
+
+ public List<Element> getAllChildren()
+ {
+ if (allChildren == null)
+ {
+ allChildren = new ArrayList<Element>();
+ for (Element child : children)
+ {
+ recurseChildren(child);
+ }
+ }
+
+ return allChildren;
+ }
+
+ private void recurseChildren(Element element)
+ {
+ allChildren.add(element);
+ for (Element child : element.getChildren())
+ {
+ recurseChildren(child);
+ }
+ }
+
+ public Element getChild(Element childElement)
+ {
+ List<Element> allChildren = getAllChildren();
+ int index = allChildren.indexOf(childElement);
+ if (index != -1)
+ {
+ return allChildren.get(index);
+ }
+
+ return null;
}
@Override
@@ -313,9 +351,14 @@ public class Release
return true;
}
+ public boolean isUnresolved()
+ {
+ return version.equals(Version.emptyVersion);
+ }
+
private void resolveVersion()
{
- if (version.equals(Version.emptyVersion))
+ if (isUnresolved())
{
Version resolvedVersion;
if (type == Element.Type.PLUGIN)
@@ -346,24 +389,15 @@ public class Release
return null;
}
- @SuppressWarnings("restriction")
private Version getFeatureVersion(String name)
{
- org.eclipse.pde.internal.core.ifeature.IFeatureModel[] featureModels = org.eclipse.pde.internal.core.PDECore
- .getDefault().getFeatureModelManager().getModels();
-
- for (org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel : featureModels)
+ IModel componentModel = ReleaseManager.INSTANCE.getComponentModel(this);
+ if (componentModel != null)
{
- org.eclipse.pde.internal.core.ifeature.IFeature feature = featureModel.getFeature();
- String id = feature.getId();
- if (id.equals(name))
- {
- Version version = new Version(feature.getVersion());
- return VersionUtil.normalize(version);
- }
+ return VersionBuilder.getComponentVersion(componentModel);
}
- return null;
+ return version;
}
/**
@@ -402,7 +436,7 @@ public class Release
else if (INCLUDES_TAG.equalsIgnoreCase(qName))
{
Element child = createElement(attributes);
- parent.getContent().add(child);
+ parent.getChildren().add(child);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/ReleaseManager.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/ReleaseManager.java
index 8e6b7aee2a..98701495af 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/ReleaseManager.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/ReleaseManager.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.IModel;
import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.core.plugin.PluginRegistry;
import org.osgi.framework.Version;
import org.xml.sax.SAXException;
@@ -36,6 +37,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.WeakHashMap;
/**
@@ -107,6 +109,7 @@ public class ReleaseManager
Release release = new Release(file);
String path = file.getFullPath().toString();
+ Map<Element, Element> elements = release.getElements();
for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects())
{
if (project.isOpen())
@@ -126,7 +129,7 @@ public class ReleaseManager
{
IModel componentModel = VersionBuilder.getComponentModel(project);
Element element = createElement(componentModel, true);
- release.getElements().put(element, element);
+ elements.put(element, element);
}
}
}
@@ -134,6 +137,27 @@ public class ReleaseManager
}
}
+ Set<Element> keySet = elements.keySet();
+ for (Element element : keySet.toArray(new Element[keySet.size()]))
+ {
+ for (Element child : element.getChildren())
+ {
+ if (!elements.containsKey(child))
+ {
+ IModel childModel = getComponentModel(child);
+ if (childModel != null)
+ {
+ Element topElement = createElement(childModel, true);
+ elements.put(topElement, topElement);
+ }
+ else
+ {
+ elements.put(child, child);
+ }
+ }
+ }
+ }
+
release.write();
releases.put(release, file.getLocalTimeStamp());
return release;
@@ -174,16 +198,73 @@ public class ReleaseManager
for (org.eclipse.pde.internal.core.ifeature.IFeatureChild versionable : feature.getIncludedFeatures())
{
Element child = new Element(Element.Type.FEATURE, versionable.getId(), versionable.getVersion());
- element.getContent().add(child);
+ element.getChildren().add(child);
}
for (org.eclipse.pde.internal.core.ifeature.IFeaturePlugin versionable : feature.getPlugins())
{
Element child = new Element(Element.Type.PLUGIN, versionable.getId(), versionable.getVersion());
- element.getContent().add(child);
+ element.getChildren().add(child);
}
}
return element;
}
+
+ @SuppressWarnings("restriction")
+ public IModel getComponentModel(Element element)
+ {
+ String name = element.getName();
+ if (element.getType() == Element.Type.PLUGIN)
+ {
+ IModel pluginModel = PluginRegistry.findModel(name);
+ if (pluginModel != null)
+ {
+ return pluginModel;
+ }
+ }
+
+ org.eclipse.pde.internal.core.FeatureModelManager manager = org.eclipse.pde.internal.core.PDECore.getDefault()
+ .getFeatureModelManager();
+ org.eclipse.pde.internal.core.ifeature.IFeatureModel[] featureModels = manager.getWorkspaceModels();
+
+ org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel = getFeatureModel(name, featureModels);
+ if (featureModel == null)
+ {
+ featureModels = manager.getExternalModels();
+ featureModel = getFeatureModel(name, featureModels);
+ }
+
+ return featureModel;
+ }
+
+ @SuppressWarnings("restriction")
+ private org.eclipse.pde.internal.core.ifeature.IFeatureModel getFeatureModel(String name,
+ org.eclipse.pde.internal.core.ifeature.IFeatureModel[] featureModels)
+ {
+ Version highestVersion = null;
+ org.eclipse.pde.internal.core.ifeature.IFeatureModel highestModel = null;
+
+ for (org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel : featureModels)
+ {
+ org.eclipse.pde.internal.core.ifeature.IFeature feature = featureModel.getFeature();
+ String id = feature.getId();
+ if (id.equals(name))
+ {
+ Version newVersion = new Version(feature.getVersion());
+ if (highestVersion == null || highestVersion.compareTo(newVersion) < 0)
+ {
+ highestVersion = newVersion;
+ highestModel = featureModel;
+ }
+ }
+ }
+
+ if (highestModel == null)
+ {
+ return null;
+ }
+
+ return highestModel;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionBuilder.java b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionBuilder.java
index 7b527cf27d..dd5f224f62 100644
--- a/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionBuilder.java
+++ b/plugins/org.eclipse.emf.cdo.releng.version/src/org/eclipse/emf/cdo/releng/version/VersionBuilder.java
@@ -60,6 +60,8 @@ public class VersionBuilder extends IncrementalProjectBuilder
private static final Path FEATURE_PATH = new Path("feature.xml");
+ private static final Version REMOVAL = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
+
private static final int NO_CHANGE = 0;
private static final int MICRO_CHANGE = 1;
@@ -193,7 +195,7 @@ public class VersionBuilder extends IncrementalProjectBuilder
else
{
List<Map.Entry<Element, Version>> warnings = new ArrayList<Entry<Element, Version>>();
- int change = checkFeatureAPI(componentModel, buildDpependencies, warnings);
+ int change = checkFeatureAPI(componentModel, element, releaseElement, buildDpependencies, warnings);
if (change != NO_CHANGE)
{
Version nextFeatureVersion = null;
@@ -305,81 +307,98 @@ public class VersionBuilder extends IncrementalProjectBuilder
}
@SuppressWarnings("restriction")
- private int checkFeatureAPI(IModel componentModel, List<IProject> buildDpependencies,
- List<Entry<Element, Version>> warnings)
+ private int checkFeatureAPI(IModel componentModel, Element element, Element releasedElement,
+ List<IProject> buildDpependencies, List<Entry<Element, Version>> warnings)
{
org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel = (org.eclipse.pde.internal.core.ifeature.IFeatureModel)componentModel;
org.eclipse.pde.internal.core.ifeature.IFeature feature = featureModel.getFeature();
- int biggestChange = NO_CHANGE;
for (org.eclipse.pde.internal.core.ifeature.IFeatureChild versionable : feature.getIncludedFeatures())
{
- String id = versionable.getId();
- Element element = new Element(Element.Type.FEATURE, id, versionable.getVersion());
- int change = checkFeatureAPI(element, warnings);
+ Element childElement = new Element(Element.Type.FEATURE, versionable.getId(), versionable.getVersion());
+ element.getChildren().add(childElement);
+ }
+
+ for (org.eclipse.pde.internal.core.ifeature.IFeaturePlugin versionable : feature.getPlugins())
+ {
+ Element childElement = new Element(Element.Type.PLUGIN, versionable.getId(), versionable.getVersion());
+ element.getChildren().add(childElement);
+ }
+
+ int biggestChange = NO_CHANGE;
+ List<Element> allChildren = element.getAllChildren();
+ for (Element child : allChildren)
+ {
+ int change = checkFeatureAPI(element, releasedElement, child, warnings);
biggestChange = Math.max(biggestChange, change);
- IProject project = getFeatureProject(id);
+ String name = child.getName();
+ IProject project = child.getType() == Element.Type.PLUGIN ? getPluginProject(name) : getFeatureProject(name);
if (project != null)
{
buildDpependencies.add(project);
}
}
- for (org.eclipse.pde.internal.core.ifeature.IFeaturePlugin versionable : feature.getPlugins())
+ for (Element releasedElementsChild : releasedElement.getAllChildren())
{
- Element element = new Element(Element.Type.PLUGIN, versionable.getId(), versionable.getVersion());
- int change = checkFeatureAPI(element, warnings);
- biggestChange = Math.max(biggestChange, change);
-
- IProject project = getPluginProject(versionable.getId());
- if (project != null)
+ if (!allChildren.contains(releasedElementsChild))
{
- buildDpependencies.add(project);
+ addWarning(releasedElementsChild, REMOVAL, warnings);
+ biggestChange = MAJOR_CHANGE; // REMOVAL
}
}
return biggestChange;
}
- private int checkFeatureAPI(Element element, List<Entry<Element, Version>> warnings)
+ private int checkFeatureAPI(Element element, Element releasedElement, Element childElement,
+ List<Entry<Element, Version>> warnings)
{
- // TODO Removal --> MAJOR_CHANGE
+ if (childElement.isUnresolved())
+ {
+ return NO_CHANGE;
+ }
- Element releasedElement = release.getElements().get(element);
- if (releasedElement != null)
+ Element releasedElementsChild = releasedElement.getChild(childElement);
+ if (releasedElementsChild == null)
{
- Version releasedVersion = releasedElement.getVersion();
- Version version = element.getVersion();
+ addWarning(childElement, null, warnings);
+ return MINOR_CHANGE; // ADDITION
+ }
- if (version == null)
- {
- return NO_CHANGE;
- }
+ Element childsReleasedElement = release.getElements().get(childElement);
+ if (childsReleasedElement == null)
+ {
+ return NO_CHANGE;
+ }
- if (version.getMajor() != releasedVersion.getMajor())
- {
- addWarning(releasedElement, version, warnings);
- return MAJOR_CHANGE;
- }
+ Version releasedVersion = childsReleasedElement.getVersion();
+ Version version = childElement.getVersion();
+ if (version == null)
+ {
+ return NO_CHANGE;
+ }
- if (version.getMinor() != releasedVersion.getMinor())
- {
- addWarning(releasedElement, version, warnings);
- return MINOR_CHANGE;
- }
+ if (version.getMajor() != releasedVersion.getMajor())
+ {
+ addWarning(childsReleasedElement, version, warnings);
+ return MAJOR_CHANGE;
+ }
- if (version.getMicro() != releasedVersion.getMicro())
- {
- addWarning(releasedElement, version, warnings);
- return MICRO_CHANGE;
- }
+ if (version.getMinor() != releasedVersion.getMinor())
+ {
+ addWarning(childsReleasedElement, version, warnings);
+ return MINOR_CHANGE;
+ }
- return NO_CHANGE;
+ if (version.getMicro() != releasedVersion.getMicro())
+ {
+ addWarning(childsReleasedElement, version, warnings);
+ return MICRO_CHANGE;
}
- // Addition
- return MINOR_CHANGE;
+ return NO_CHANGE;
}
private void addWarning(final Element releasedElement, final Version version,
@@ -423,7 +442,7 @@ public class VersionBuilder extends IncrementalProjectBuilder
private IProject getFeatureProject(String name)
{
org.eclipse.pde.internal.core.ifeature.IFeatureModel[] featureModels = org.eclipse.pde.internal.core.PDECore
- .getDefault().getFeatureModelManager().getModels();
+ .getDefault().getFeatureModelManager().getWorkspaceModels();
for (org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel : featureModels)
{
@@ -620,11 +639,29 @@ public class VersionBuilder extends IncrementalProjectBuilder
try
{
String name = releasedElement.getName();
- String regex = "<" + tag + "\\s+.*?id\\s*=\\s*[\"'](" + name.replace(".", "\\.") + ")";
- String msg = type + " reference '" + name + "' has changed from " + releasedElement.getVersion() + " to "
- + version;
- Markers.addMarker(file, msg, IMarker.SEVERITY_WARNING, regex);
+ if (version == REMOVAL)
+ {
+ String msg = type + " reference '" + name + "' has been removed";
+ Markers.addMarker(file, msg, IMarker.SEVERITY_WARNING);
+ }
+ else
+ {
+ String regex = "<" + tag + "\\s+.*?id\\s*=\\s*[\"'](" + name.replace(".", "\\.") + ")";
+ String msg;
+
+ if (version == null)
+ {
+ msg = type + " reference '" + name + "' has been added with " + releasedElement.getVersion();
+ }
+ else
+ {
+ msg = type + " reference '" + name + "' has been changed from " + releasedElement.getVersion() + " to "
+ + version;
+ }
+
+ Markers.addMarker(file, msg, IMarker.SEVERITY_WARNING, regex);
+ }
}
catch (Exception ex)
{
@@ -673,41 +710,16 @@ public class VersionBuilder extends IncrementalProjectBuilder
}
@SuppressWarnings("restriction")
- public static IModel getComponentModel(Element element)
- {
- String name = element.getName();
- if (element.getType() == Element.Type.PLUGIN)
- {
- IModel pluginModel = PluginRegistry.findModel(name);
- if (pluginModel != null)
- {
- return pluginModel;
- }
- }
-
- org.eclipse.pde.internal.core.ifeature.IFeatureModel[] featureModels = org.eclipse.pde.internal.core.PDECore
- .getDefault().getFeatureModelManager().getWorkspaceModels();
-
- for (org.eclipse.pde.internal.core.ifeature.IFeatureModel featureModel : featureModels)
- {
- if (featureModel.getFeature().getId().equals(name))
- {
- return featureModel;
- }
- }
-
- return null;
- }
-
- @SuppressWarnings("restriction")
public static Version getComponentVersion(IModel componentModel)
{
if (componentModel instanceof IPluginModelBase)
{
IPluginModelBase pluginModel = (IPluginModelBase)componentModel;
- return pluginModel.getBundleDescription().getVersion();
+ return VersionUtil.normalize(pluginModel.getBundleDescription().getVersion());
}
- return new Version(((org.eclipse.pde.internal.core.ifeature.IFeatureModel)componentModel).getFeature().getVersion());
+ Version version = new Version(((org.eclipse.pde.internal.core.ifeature.IFeatureModel)componentModel).getFeature()
+ .getVersion());
+ return VersionUtil.normalize(version);
}
}

Back to the top