FELIX-2819: consider packageinfo files contained in src/main/java
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1139399 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 7a43d2c..76073bc 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -25,11 +25,22 @@
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.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.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 @@
}
- 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 @@
{
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 ) );
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
index 0851e44..fc3df49 100644
--- a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
@@ -196,5 +196,15 @@
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 );
+ }
}
diff --git a/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo
new file mode 100644
index 0000000..572746d
--- /dev/null
+++ b/bundleplugin/src/test/java/org/apache/felix/bundleplugin/packageinfo
@@ -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