FELIX-840: Ignore invalid scr files in dependent bundles.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@722090 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
index 5214158..48035e2 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
@@ -158,7 +158,10 @@
while ( st.hasMoreTokens() ) {
final String entry = st.nextToken().trim();
if ( entry.length() > 0 ) {
- components.addAll(this.readServiceComponentDescriptor(artifact, entry).getComponents());
+ final Components c = this.readServiceComponentDescriptor(artifact, entry);
+ if ( c != null ) {
+ components.addAll(c.getComponents());
+ }
}
}
} else {
@@ -242,18 +245,26 @@
* @throws IOException
* @throws MojoExecutionException
*/
- protected Components readServiceComponentDescriptor(Artifact artifact, String entry)
- throws IOException, MojoExecutionException {
+ protected Components readServiceComponentDescriptor(Artifact artifact, String entry) {
this.log.debug("Reading " + entry + " from " + artifact);
- final File xml = this.getFile(artifact, entry);
- if ( xml == null ) {
- throw new MojoExecutionException("Artifact " + artifact + " does not contain declared service component descriptor " + entry);
+ try {
+ final File xml = this.getFile(artifact, entry);
+ if ( xml == null ) {
+ throw new MojoExecutionException("Artifact " + artifact + " does not contain declared service component descriptor " + entry);
+ }
+ return this.parseServiceComponentDescriptor(artifact, xml);
+ } catch (IOException mee) {
+ this.log.warn("Unable to read SCR descriptor file from artifact " + artifact + " at " + entry);
+ this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
+ } catch (MojoExecutionException mee) {
+ this.log.warn("Unable to read SCR descriptor file from artifact " + artifact + " at " + entry);
+ this.log.debug("Exception occurred during reading: " + mee.getMessage(), mee);
}
- return this.parseServiceComponentDescriptor(artifact, xml);
+ return null;
}
protected Components parseServiceComponentDescriptor(Artifact artifact, File file)
- throws IOException, MojoExecutionException {
+ throws MojoExecutionException {
this.log.debug("Parsing " + file);
final Components list = ComponentDescriptorIO.read(file);
return list;
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index 9b0ecab..627ef5e 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -78,7 +78,7 @@
IOUtils.parse(file, xmlHandler);
return xmlHandler.components;
} catch (TransformerException e) {
- throw new MojoExecutionException("Unable to read xml.", e);
+ throw new MojoExecutionException("Unable to read xml from " + file, e);
} catch (IOException e) {
throw new MojoExecutionException("Unable to read xml from " + file, e);
}
@@ -283,14 +283,10 @@
IOUtils.addAttribute(ai, "cardinality", reference.getCardinality());
IOUtils.addAttribute(ai, "policy", reference.getPolicy());
IOUtils.addAttribute(ai, "target", reference.getTarget());
-
- if (!reference.isLookupStrategy()) {
- IOUtils.addAttribute(ai, "bind", reference.getBind());
- IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
- }
+ IOUtils.addAttribute(ai, "bind", reference.getBind());
+ IOUtils.addAttribute(ai, "unbind", reference.getUnbind());
if ( isScrPrivateFile ) {
IOUtils.addAttribute(ai, "checked", String.valueOf(reference.isChecked()));
- IOUtils.addAttribute(ai, "strategy", reference.getStrategy());
}
IOUtils.indent(contentHandler, 2);
contentHandler.startElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.REFERENCE, ComponentDescriptorIO.REFERENCE_QNAME, ai);
@@ -424,7 +420,6 @@
ref.setTarget(attributes.getValue("target"));
ref.setBind(attributes.getValue("bind"));
ref.setUnbind(attributes.getValue("unbind"));
- ref.setStrategy(attributes.getValue("strategy"));
if ( attributes.getValue("checked") != null ) {
ref.setChecked(Boolean.valueOf(attributes.getValue("checked")).booleanValue());