SLING-6254 find the pom.xml with arbitrary GAVs to also supported forked Jetty bundles
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1768712 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java b/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
index b9d1ee5..704cfd8 100644
--- a/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
+++ b/src/main/java/org/apache/sling/tooling/support/source/impl/FelixJettySourceReferenceFinder.java
@@ -20,6 +20,7 @@
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
@@ -45,33 +46,36 @@
if ( !(jettyVersion instanceof String) ) {
return Collections.emptyList();
}
-
- URL entry = bundle.getEntry("/META-INF/maven/org.apache.felix/org.apache.felix.http.jetty/pom.xml");
-
- InputStream pom = null;
- try {
- pom = entry.openStream();
-
+ Enumeration entries = bundle.findEntries("META-INF/maven", "pom.xml", true);
+ if (entries != null && entries.hasMoreElements()) {
+ URL entry = (URL)entries.nextElement();
+ InputStream pom = null;
try {
- SAXParserFactory parserFactory = SAXParserFactory.newInstance();
- SAXParser parser = parserFactory.newSAXParser();
- PomHandler handler = new PomHandler((String) jettyVersion);
- parser.parse(new InputSource(pom), handler);
+ pom = entry.openStream();
- return handler.getReferences();
- } catch (SAXException e) {
- throw new SourceReferenceException(e);
- } catch (ParserConfigurationException e) {
+ try {
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ SAXParser parser = parserFactory.newSAXParser();
+ PomHandler handler = new PomHandler((String) jettyVersion);
+ parser.parse(new InputSource(pom), handler);
+
+ return handler.getReferences();
+ } catch (SAXException e) {
+ throw new SourceReferenceException(e);
+ } catch (ParserConfigurationException e) {
+ throw new SourceReferenceException(e);
+ } finally {
+ IOUtils.closeQuietly(pom);
+ }
+ } catch (IOException e) {
throw new SourceReferenceException(e);
} finally {
IOUtils.closeQuietly(pom);
}
- } catch (IOException e) {
- throw new SourceReferenceException(e);
- } finally {
- IOUtils.closeQuietly(pom);
+
+ } else {
+ return Collections.emptyList();
}
-
}
}