sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-tooling-support-source] 05/14: SLING-6254 find the pom.xml with arbitrary GAVs to also supported forked Jetty bundles
Date Wed, 18 Oct 2017 23:30:46 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-tooling-support-source.git

commit cdd833f3de027ba49596db7b4b103abe17a9cff6
Author: Konrad Windszus <kwin@apache.org>
AuthorDate: Tue Nov 8 15:17:28 2016 +0000

    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
---
 .../impl/FelixJettySourceReferenceFinder.java      | 44 ++++++++++++----------
 1 file changed, 24 insertions(+), 20 deletions(-)

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.IOException;
 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 @@ public class FelixJettySourceReferenceFinder implements SourceReferenceFinder
{
         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();
         }
-
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Mime
View raw message