felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r596051 - /felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Date Sun, 18 Nov 2007 04:36:21 GMT
Author: mcculls
Date: Sat Nov 17 20:36:21 2007
New Revision: 596051

URL: http://svn.apache.org/viewvc?rev=596051&view=rev
Log:
FELIX-400: add resource code to properly handle Maven includes/excludes

Modified:
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=596051&r1=596050&r2=596051&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
(original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Sat Nov 17 20:36:21 2007
@@ -43,6 +43,7 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+import org.codehaus.plexus.util.DirectoryScanner;
 
 import aQute.lib.osgi.Analyzer;
 import aQute.lib.osgi.Builder;
@@ -126,6 +127,8 @@
 
     private static final String MAVEN_RESOURCES = "{maven-resources}";
     private static final String MAVEN_RESOURCES_REGEX = "\\{maven-resources\\}";
+    private static final String[] EMPTY_STRING_ARRAY = {};
+    private static final String[] DEFAULT_INCLUDES = {"**/**"};
 
 
     protected Maven2OsgiConverter getMaven2OsgiConverter()
@@ -596,47 +599,73 @@
             // ignore empty or non-local resources
             if (new File(sourcePath).exists() && ((targetPath == null) || (targetPath.indexOf("..")
< 0)))
             {
-                String path = sourcePath;
+                DirectoryScanner scanner = new DirectoryScanner();
 
-                // make relative to project
-                if (path.startsWith(basePath))
+                scanner.setBasedir( resource.getDirectory() );
+                if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty()
)
                 {
-                    if ( path.length() == basePath.length() )
-                    {
-                        path = ".";
-                    }
-                    else
-                    {
-                        path = path.substring( basePath.length() + 1 );
-                    }
+                    scanner.setIncludes( (String[]) resource.getIncludes().toArray( EMPTY_STRING_ARRAY
) );
                 }
-                // replace windows backslash with a slash
-                // this is a workaround for a problem with bnd 0.0.189
-                if ( File.separatorChar != '/' )
+                else
                 {
-                    path = path.replace(File.separatorChar, '/');
+                    scanner.setIncludes( DEFAULT_INCLUDES );
                 }
 
-                if (targetPath != null)
+                if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty()
)
                 {
-                    path = targetPath + '=' + path;
+                    scanner.setExcludes( (String[]) resource.getExcludes().toArray( EMPTY_STRING_ARRAY
) );
                 }
 
-                if (resourcePaths.length() > 0)
-                {
-                    resourcePaths.append(',');
-                }
+                scanner.addDefaultExcludes();
+                scanner.scan();
 
-                if (resource.isFiltering())
-                {
-                    resourcePaths.append('{');
-                    resourcePaths.append(path);
-                    resourcePaths.append('}');
-                }
-                else
+                List includedFiles = Arrays.asList( scanner.getIncludedFiles() );
+
+                for ( Iterator j = includedFiles.iterator(); j.hasNext(); )
                 {
-                    resourcePaths.append(path);
-                }
+                    String path = sourcePath + '/' + j.next();
+
+                    // make relative to project
+                    if (path.startsWith(basePath))
+                    {
+                        if ( path.length() == basePath.length() )
+                        {
+                            path = ".";
+                        }
+                        else
+                        {
+                            path = path.substring( basePath.length() + 1 );
+                        }
+                    }
+
+                    // replace windows backslash with a slash
+                    // this is a workaround for a problem with bnd 0.0.189
+                    if ( File.separatorChar != '/' )
+                    {
+                        path = path.replace(File.separatorChar, '/');
+                    }
+
+                    if (targetPath != null)
+                    {
+                        path = targetPath + '=' + path;
+                    }
+
+                    if (resourcePaths.length() > 0)
+                    {
+                        resourcePaths.append(',');
+                    }
+
+                    if (resource.isFiltering())
+                    {
+                        resourcePaths.append('{');
+                        resourcePaths.append(path);
+                        resourcePaths.append('}');
+                    }
+                    else
+                    {
+                        resourcePaths.append(path);
+                    }
+                }                
             }
         }
 



Mime
View raw message