summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2012-07-10 12:27:29 (EDT)
committerPascal Rapicault2012-07-10 12:27:29 (EDT)
commite6ed13212ea5c1a7daaf8f9d52f5a885b0929e1f (patch)
tree06232a07ecf91a909e435c556442047768299802
parentffeddcac921157a66d827325325ce5fbde418ff7 (diff)
downloadrt.equinox.p2-e6ed13212ea5c1a7daaf8f9d52f5a885b0929e1f.zip
rt.equinox.p2-e6ed13212ea5c1a7daaf8f9d52f5a885b0929e1f.tar.gz
rt.equinox.p2-e6ed13212ea5c1a7daaf8f9d52f5a885b0929e1f.tar.bz2
Bug 384753 - [publisher] support for p2ql in update descriptor v20120710-162729
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java22
2 files changed, 36 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
index 398ff0b..4d3caf5 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
@@ -17,7 +17,7 @@ import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
+import org.eclipse.equinox.p2.metadata.expression.*;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
public class AdviceFileParser {
@@ -31,6 +31,7 @@ public class AdviceFileParser {
private static final String UPDATE_SEVERITY = "update.severity"; //$NON-NLS-1$
private static final String UPDATE_RANGE = "update.range"; //$NON-NLS-1$
private static final String UPDATE_ID = "update.id"; //$NON-NLS-1$
+ private static final String UPDATE_MATCH = "update.match"; //$NON-NLS-1$
private static final String CLASSIFIER = "classifier"; //$NON-NLS-1$
private static final String TOUCHPOINT_VERSION = "touchpoint.version"; //$NON-NLS-1$
private static final String TOUCHPOINT_ID = "touchpoint.id"; //$NON-NLS-1$
@@ -168,10 +169,13 @@ public class AdviceFileParser {
String description = null;
String range = "[0.0.0,$version$)"; //$NON-NLS-1$
String severity = "0"; //$NON-NLS-1$
+ String match = null;
while (current != null && current.startsWith(prefix)) {
String token = current;
- if (token.equals(UPDATE_ID)) {
+ if (token.equals(UPDATE_MATCH)) {
+ match = currentValue();
+ } else if (token.equals(UPDATE_ID)) {
name = currentValue();
} else if (token.equals(UPDATE_DESCRIPTION)) {
description = currentValue();
@@ -185,6 +189,14 @@ public class AdviceFileParser {
next();
}
+ if (match != null) {
+ //When update.match is specified, versionRange and id are ignored
+ IExpression expr = ExpressionUtil.parse(substituteVersionAndQualifier(match));
+ IMatchExpression matchExpression = ExpressionUtil.getFactory().matchExpression(expr);
+ Collection<IMatchExpression<IInstallableUnit>> descriptors = new ArrayList<IMatchExpression<IInstallableUnit>>(1);
+ descriptors.add(matchExpression);
+ return MetadataFactory.createUpdateDescriptor(descriptors, Integer.valueOf(severity), description, (URI) null);
+ }
range = substituteVersionAndQualifier(range);
VersionRange versionRange = new VersionRange(range);
return MetadataFactory.createUpdateDescriptor(name, versionRange, Integer.valueOf(severity), description);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
index 1325f96..9c752ba 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java
@@ -85,6 +85,28 @@ public class AdviceFileParserTest extends TestCase {
assertEquals("Test Description", updateDescriptor.getDescription());
}
+ public void testUpdateDescriptorWithMatch() {
+ Map map = new HashMap();
+ map.put("update.match", "providedCapabilities.exists(pc | pc.namespace == 'org.eclipse.equinox.p2.iu' && (pc.name == 'B' || pc.name == 'C'))");
+ map.put("update.severity", "10");
+ map.put("update.description", "Test Description");
+
+ AdviceFileParser parser = new AdviceFileParser("id", Version.parseVersion("9.10.11"), map);
+ parser.parse();
+
+ IUpdateDescriptor updateDescriptor = parser.getUpdateDescriptor();
+ assertEquals("Test Description", updateDescriptor.getDescription());
+ assertEquals(10, updateDescriptor.getSeverity());
+ //Here we test that the extraction of the name fails since this is not of an appropriate format
+ boolean exceptionRaised = false;
+ try {
+ RequiredCapability.extractName(updateDescriptor.getIUsBeingUpdated().iterator().next());
+ } catch (IllegalArgumentException e) {
+ exceptionRaised = true;
+ }
+ assertTrue(exceptionRaised);
+ }
+
public void testUpdateDescriptorAdviceDefaultBound2() {
Map map = new HashMap();
map.put("update.id", "testName");