You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2011/06/24 20:21:16 UTC

svn commit: r1139399 - in /felix/trunk/bundleplugin/src: main/java/org/apache/felix/bundleplugin/ test/java/org/apache/felix/bnd/ test/java/org/apache/felix/bundleplugin/ test/resources/org/apache/felix/

Author: mcculls
Date: Fri Jun 24 18:21:16 2011
New Revision: 1139399

URL: http://svn.apache.org/viewvc?rev=1139399&view=rev
Log:
FELIX-2819: consider packageinfo files contained in src/main/java

Added:
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo
Removed:
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bnd/
    felix/trunk/bundleplugin/src/test/resources/org/apache/felix/
Modified:
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.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=1139399&r1=1139398&r2=1139399&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 Fri Jun 24 18:21:16 2011
@@ -25,11 +25,22 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
-import aQute.lib.osgi.*;
 import org.apache.maven.archiver.ManifestSection;
 import org.apache.maven.archiver.MavenArchiveConfiguration;
 import org.apache.maven.archiver.MavenArchiver;
@@ -37,6 +48,7 @@ import org.apache.maven.artifact.Artifac
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.model.License;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -51,6 +63,13 @@ import org.codehaus.plexus.util.Director
 import org.codehaus.plexus.util.StringInputStream;
 import org.codehaus.plexus.util.StringUtils;
 
+import aQute.lib.osgi.Analyzer;
+import aQute.lib.osgi.Builder;
+import aQute.lib.osgi.Constants;
+import aQute.lib.osgi.EmbeddedResource;
+import aQute.lib.osgi.FileResource;
+import aQute.lib.osgi.Jar;
+import aQute.lib.osgi.Processor;
 import aQute.lib.spring.SpringXMLType;
 
 
@@ -1075,14 +1094,33 @@ public class BundlePlugin extends Abstra
     }
 
 
-    private static String getMavenResourcePaths( MavenProject project )
+    private static List getMavenResources( MavenProject project )
+    {
+        List resources = new ArrayList(project.getResources());
+
+        // also scan for any "packageinfo" files lurking in the source folders
+        List packageInfoIncludes = Collections.singletonList( "**/packageinfo" );
+        for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
+        {
+            String sourceRoot = (String) i.next();
+            Resource packageInfoResource = new Resource();
+            packageInfoResource.setDirectory( sourceRoot );
+            packageInfoResource.setIncludes( packageInfoIncludes );
+            resources.add( packageInfoResource );
+        }
+
+        return resources;
+    }
+
+
+    protected static String getMavenResourcePaths( MavenProject project )
     {
         final String basePath = project.getBasedir().getAbsolutePath();
 
         Set pathSet = new LinkedHashSet();
-        for ( Iterator i = project.getResources().iterator(); i.hasNext(); )
+        for ( Iterator i = getMavenResources( project ).iterator(); i.hasNext(); )
         {
-            org.apache.maven.model.Resource resource = ( org.apache.maven.model.Resource ) i.next();
+            Resource resource = ( Resource ) i.next();
 
             final String sourcePath = resource.getDirectory();
             final String targetPath = resource.getTargetPath();
@@ -1092,7 +1130,7 @@ public class BundlePlugin extends Abstra
             {
                 DirectoryScanner scanner = new DirectoryScanner();
 
-                scanner.setBasedir( resource.getDirectory() );
+                scanner.setBasedir( sourcePath );
                 if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
                 {
                     scanner.setIncludes( ( String[] ) resource.getIncludes().toArray( EMPTY_STRING_ARRAY ) );

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java?rev=1139399&r1=1139398&r2=1139399&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java Fri Jun 24 18:21:16 2011
@@ -196,5 +196,15 @@ public class BundlePluginTest extends Ab
         String cleanupVersion = Builder.cleanupVersion( "0.0.0.4aug2000r7-dev" );
         assertEquals( "0.0.0.4aug2000r7-dev", cleanupVersion );
     }
+    
+    public void testPackageInfoDetection() throws Exception
+    {
+        MavenProject project = new MavenProjectStub();
+        project.addCompileSourceRoot( getBasedir() + "/src/test/java" );
 
+        String resourcePaths = plugin.getMavenResourcePaths( project );
+
+        assertEquals( "org/apache/felix/bundleplugin/packageinfo=" +
+                      "src/test/java/org/apache/felix/bundleplugin/packageinfo", resourcePaths );
+    }
 }

Added: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo?rev=1139399&view=auto
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo (added)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo Fri Jun 24 18:21:16 2011
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+packageinfo:
+    version 888