You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2012/08/04 13:02:36 UTC
svn commit: r1369295 - in /ant/ivy/core/trunk/src/java/org/apache/ivy/osgi:
core/ManifestParser.java p2/P2Descriptor.java p2/P2MetadataParser.java
Author: hibou
Date: Sat Aug 4 11:02:36 2012
New Revision: 1369295
URL: http://svn.apache.org/viewvc?rev=1369295&view=rev
Log:
Make the error handling be less destructive: just log verbose and ignore the weird bundle
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java?rev=1369295&r1=1369294&r2=1369295&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java Sat Aug 4 11:02:36 2012
@@ -102,11 +102,12 @@ public class ManifestParser {
public static BundleInfo parseManifest(Manifest manifest) throws ParseException {
Attributes mainAttributes = manifest.getMainAttributes();
- String manifestVersion = mainAttributes.getValue(BUNDLE_MANIFEST_VERSION);
- if (manifestVersion == null) {
- // non OSGi manifest
- throw new ParseException("No " + BUNDLE_MANIFEST_VERSION + " in the manifest", 0);
- }
+ // Eclipse source bundle doesn't have it. Disable it until proven actually useful
+ // String manifestVersion = mainAttributes.getValue(BUNDLE_MANIFEST_VERSION);
+ // if (manifestVersion == null) {
+ // // non OSGi manifest
+ // throw new ParseException("No " + BUNDLE_MANIFEST_VERSION + " in the manifest", 0);
+ // }
String symbolicName = new ManifestHeaderValue(mainAttributes.getValue(BUNDLE_SYMBOLIC_NAME))
.getSingleValue();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java?rev=1369295&r1=1369294&r2=1369295&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java Sat Aug 4 11:02:36 2012
@@ -50,15 +50,25 @@ public class P2Descriptor extends RepoDe
public void addBundle(BundleInfo bundleInfo) {
if (bundleInfo.isSource()) {
+ if (bundleInfo.getSymbolicNameTarget() == null || bundleInfo.getVersionTarget() == null) {
+ Message.verbose("The source bundle " + bundleInfo.getSymbolicName()
+ + " did declare its target. Ignoring it");
+ return;
+ }
Map/*<String, URI>*/ byVersion = (Map) sourceURIs.get(bundleInfo.getSymbolicNameTarget());
if (byVersion == null) {
byVersion = new HashMap();
sourceURIs.put(bundleInfo.getSymbolicNameTarget(), byVersion);
}
URI sourceUri = getArtifactURI(bundleInfo);
+ if (sourceUri == null) {
+ Message.verbose("The source bundle " + bundleInfo.getSymbolicName()
+ + " has no actual artifact. Ignoring it");
+ return;
+ }
URI old = (URI) byVersion.put(bundleInfo.getVersionTarget().toString(), sourceUri);
if (old != null) {
- Message.debug("Duplicate source for the bundle "
+ Message.verbose("Duplicate source for the bundle "
+ bundleInfo.getSymbolicNameTarget() + "@" + bundleInfo.getVersionTarget()
+ " : " + sourceUri + " is replacing " + old);
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java?rev=1369295&r1=1369294&r2=1369295&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java Sat Aug 4 11:02:36 2012
@@ -191,8 +191,8 @@ public class P2MetadataParser implements
addChild(new UnitHandler(), new ChildElementHandler() {
public void childHanlded(DelegetingHandler child) {
BundleInfo bundleInfo = ((UnitHandler) child).bundleInfo;
- if (!bundleInfo.getCapabilities().isEmpty()) {
- bundles.add(((UnitHandler) child).bundleInfo);
+ if (bundleInfo != null && !bundleInfo.getCapabilities().isEmpty()) {
+ bundles.add(bundleInfo);
}
}
});
@@ -231,6 +231,7 @@ public class P2MetadataParser implements
if (category != null && Boolean.valueOf(category).booleanValue()) {
// this is a category definition, this is useless, skip this unit
child.getParent().skip();
+ bundleInfo = null;
}
}
});
@@ -242,6 +243,14 @@ public class P2MetadataParser implements
bundleInfo.setSource(true);
// we need to parse the manifest in the toupointData to figure out the
// targeted bundle
+ // in case we won't have the proper data in the manifest, prepare the source
+ // data from the convention
+ String symbolicName = bundleInfo.getSymbolicName();
+ if (symbolicName.endsWith(".source")) {
+ bundleInfo.setSymbolicNameTarget(symbolicName.substring(0, symbolicName
+ .length() - 7));
+ bundleInfo.setVersionTarget(bundleInfo.getVersion());
+ }
}
Iterator it = ((ProvidesHandler) child).capabilities.iterator();
while (it.hasNext()) {
@@ -285,41 +294,44 @@ public class P2MetadataParser implements
}
String manifest = ((TouchpointDataHandler) child).manifest;
if (manifest != null) {
+ // Eclipse may have serialized a little bit weirdly
+ manifest = ManifestParser.formatLines(manifest.trim());
+ BundleInfo embeddedInfo;
try {
- // Eclipse may have serialized a little bit weirdly
- manifest = ManifestParser.formatLines(manifest.trim());
- BundleInfo embeddedInfo = ManifestParser.parseManifest(manifest);
- if (!embeddedInfo.isSource()) {
- throw new SAXParseException(
- "Expecting an embedded manifest declaring being a source",
- child.getLocator());
- }
- String symbolicNameTarget = embeddedInfo.getSymbolicNameTarget();
- if (symbolicNameTarget == null) {
- throw new SAXParseException(
- "Expecting a symbolic name in the source header of the embedded manifest",
- child.getLocator());
- }
- Version versionTarget = embeddedInfo.getVersionTarget();
- if (versionTarget == null) {
- throw new SAXParseException(
- "Expecting a version in the source header of the embedded manifest",
- child.getLocator());
- }
- bundleInfo.setSymbolicNameTarget(symbolicNameTarget);
- bundleInfo.setVersionTarget(versionTarget);
+ embeddedInfo = ManifestParser.parseManifest(manifest);
} catch (IOException e) {
- // now way, we are in ram
- SAXParseException spe = new SAXParseException(e.getMessage(), child
- .getLocator());
- spe.initCause(e);
- throw spe;
+ Message.verbose("The Manifest of the source bundle "
+ + bundleInfo.getSymbolicName() + " could not be parsed: "
+ + e.getMessage());
+ return;
} catch (ParseException e) {
- SAXParseException spe = new SAXParseException(e.getMessage(), child
- .getLocator());
- spe.initCause(e);
- throw spe;
+ Message.verbose("The Manifest of the source bundle "
+ + bundleInfo.getSymbolicName() + " is ill formed: "
+ + e.getMessage());
+ return;
+ }
+ if (!embeddedInfo.isSource()) {
+ Message.verbose("The Manifest of the source bundle "
+ + bundleInfo.getSymbolicName()
+ + " is not declaring being a source.");
+ return;
+ }
+ String symbolicNameTarget = embeddedInfo.getSymbolicNameTarget();
+ if (symbolicNameTarget == null) {
+ Message.verbose("The Manifest of the source bundle "
+ + bundleInfo.getSymbolicName()
+ + " is not declaring a target symbolic name.");
+ return;
+ }
+ Version versionTarget = embeddedInfo.getVersionTarget();
+ if (versionTarget == null) {
+ Message.verbose("The Manifest of the source bundle "
+ + bundleInfo.getSymbolicName()
+ + " is not declaring a target version.");
+ return;
}
+ bundleInfo.setSymbolicNameTarget(symbolicNameTarget);
+ bundleInfo.setVersionTarget(versionTarget);
}
}
});