FELIX-5116 : Dump SCR component definitions broken. Apply patch from Stefan Seifert
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1722327 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 724a074..462a9d2 100644
--- a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -189,6 +189,18 @@
@Parameter( defaultValue = "${basedir}/dependency-reduced-pom.xml" )
protected File dependencyReducedPomLocation;
+ /**
+ * Directory where the SCR files will be written
+ */
+ @Parameter(defaultValue="${project.build.outputDirectory}")
+ protected File scrLocation;
+
+ /**
+ * When true, dump the generated SCR files
+ */
+ @Parameter
+ protected boolean exportScr;
+
@Component
private MavenProjectHelper m_projectHelper;
@@ -507,7 +519,7 @@
try
{
- ManifestPlugin.writeManifest( builder, outputFile, niceManifest );
+ ManifestPlugin.writeManifest( builder, outputFile, niceManifest, exportScr, scrLocation );
}
catch ( IOException e )
{
diff --git a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 1e1d025..ff33521 100644
--- a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -66,19 +66,6 @@
@Parameter( property = "rebuildBundle" )
protected boolean rebuildBundle;
- /**
- * Directory where the SCR files will be written
- *
- * @parameter expression="${scrLocation}" default-value="${project.build.outputDirectory}"
- */
- protected File scrLocation;
-
- /**
- * When true, dump the generated SCR files
- * @parameter
- */
- protected boolean exportScr;
-
@Override
protected void execute( MavenProject project, DependencyNode dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] classpath )
throws MojoExecutionException
@@ -112,7 +99,7 @@
try
{
- writeManifest( analyzer, outputFile, niceManifest );
+ writeManifest( analyzer, outputFile, niceManifest, exportScr, scrLocation );
}
catch ( Exception e )
{
@@ -149,32 +136,7 @@
if (exportScr)
{
- scrLocation.mkdirs();
-
- String bpHeader = analyzer.getProperty(Analyzer.SERVICE_COMPONENT);
- Parameters map = Processor.parseHeader(bpHeader, null);
- for (String root : map.keySet())
- {
- Map<String, Resource> dir = jar.getDirectories().get(root);
- File location = new File(scrLocation, root);
- if (dir == null || dir.isEmpty())
- {
- Resource resource = jar.getResource(root);
- if (resource != null)
- {
- writeSCR(resource, location);
- }
- }
- else
- {
- for (Map.Entry<String, Resource> entry : dir.entrySet())
- {
- String path = entry.getKey();
- Resource resource = entry.getValue();
- writeSCR(resource, new File(location, path));
- }
- }
- }
+ exportScr(analyzer, jar, scrLocation);
}
// cleanup...
@@ -182,8 +144,37 @@
return manifest;
}
+
+ private static void exportScr(Analyzer analyzer, Jar jar, File scrLocation) throws Exception {
+ scrLocation.mkdirs();
- protected void writeSCR(Resource resource, File destination) throws Exception
+ String bpHeader = analyzer.getProperty(Analyzer.SERVICE_COMPONENT);
+ Parameters map = Processor.parseHeader(bpHeader, null);
+ for (String root : map.keySet())
+ {
+ Map<String, Resource> dir = jar.getDirectories().get(root);
+ File location = new File(scrLocation, root);
+ if (dir == null || dir.isEmpty())
+ {
+ Resource resource = jar.getResource(root);
+ if (resource != null)
+ {
+ writeSCR(resource, location);
+ }
+ }
+ else
+ {
+ for (Map.Entry<String, Resource> entry : dir.entrySet())
+ {
+ String path = entry.getKey();
+ Resource resource = entry.getValue();
+ writeSCR(resource, new File(location, path));
+ }
+ }
+ }
+ }
+
+ private static void writeSCR(Resource resource, File destination) throws Exception
{
destination.getParentFile().mkdirs();
OutputStream os = new FileOutputStream(destination);
@@ -295,10 +286,12 @@
}
- public static void writeManifest( Analyzer analyzer, File outputFile, boolean niceManifest ) throws Exception
+ public static void writeManifest( Analyzer analyzer, File outputFile, boolean niceManifest,
+ boolean exportScr, File scrLocation ) throws Exception
{
Properties properties = analyzer.getProperties();
- Manifest manifest = analyzer.getJar().getManifest();
+ Jar jar = analyzer.getJar();
+ Manifest manifest = jar.getManifest();
if ( outputFile.exists() && properties.containsKey( "Merge-Headers" ) )
{
Manifest analyzerManifest = manifest;
@@ -321,6 +314,11 @@
parentFile.mkdirs();
}
writeManifest( manifest, outputFile, niceManifest );
+
+ if (exportScr)
+ {
+ exportScr(analyzer, jar, scrLocation);
+ }
}