You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:15:13 UTC

[sling-maven-launchpad-plugin] 30/49: SLING-1693 - implemeting a search path for resources

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag maven-launchpad-plugin-2.0.10
in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git

commit 119f7007634e7f96480ebf794d30e07651318257
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Aug 24 18:07:45 2010 +0000

    SLING-1693 - implemeting a search path for resources
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@988642 13f79535-47bb-0310-9956-ffa450edef68
---
 .../AbstractLaunchpadStartingMojo.java             | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
index 1bd8cb1..1413714 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
@@ -100,6 +100,12 @@ public abstract class AbstractLaunchpadStartingMojo extends AbstractBundleListMo
     private File propertiesFile;
 
     /**
+     * @parameter expression="${resourceProviderRoot}"
+     *           default-value="src/test/resources"
+     */
+    private File resourceProviderRoot;
+
+    /**
      * @component
      */
     private MavenFileFilter mavenFileFilter;
@@ -155,13 +161,23 @@ public abstract class AbstractLaunchpadStartingMojo extends AbstractBundleListMo
 
         @Override
         public URL getResource(String path) {
-            if (path.endsWith(".properties") || path.endsWith(".xml")) {
-                return getClass().getResource("/" + path);
+            File resourceFile = new File(resourceProviderRoot, path);
+            if (resourceFile.exists()) {
+                try {
+                    return resourceFile.toURI().toURL();
+                } catch (MalformedURLException e) {
+                    getLog().error("Unable to create URL for file", e);
+                    return null;
+                }
             } else {
+                URL fromClasspath = getClass().getResource("/" + path);
+                if (fromClasspath != null) {
+                    return fromClasspath;
+                }
+                
                 try {
                     return new URL(path);
                 } catch (MalformedURLException e) {
-                    getLog().error("Expecting a real URL", e);
                     return null;
                 }
             }

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