Author: cziegeler
Date: Sun Mar 13 09:47:18 2016
New Revision: 1734773

URL: http://svn.apache.org/viewvc?rev=1734773&view=rev
Log:
FELIX-4009 : maven bundle plugin should be integrated directly with eclipse. 
Apply patch from Stefan Seifert

Modified:
    
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
    
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
    
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
    
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java

Modified: 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java?rev=1734773&r1=1734772&r2=1734773&view=diff
==============================================================================
--- 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
 (original)
+++ 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
 Sun Mar 13 09:47:18 2016
@@ -19,7 +19,7 @@
 package org.apache.felix.bundleplugin;
 
 
-import java.io.FileOutputStream;
+import java.io.File;
 import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.Map;
@@ -75,7 +75,7 @@ public class AntPlugin extends BundlePlu
             // save the BND generated bundle to the same output directory that 
maven uses
             bndProperties.setProperty( "-output", 
"${maven.build.dir}/${maven.build.finalName}.jar" );
 
-            OutputStream out = new FileOutputStream( baseDir + BUILD_BND );
+            OutputStream out = buildContext.newFileOutputStream( new 
File(baseDir + BUILD_BND) );
             bndProperties.store( out, " Merged BND Instructions" );
             IOUtil.close( out );
 

Modified: 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=1734773&r1=1734772&r2=1734773&view=diff
==============================================================================
--- 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 (original)
+++ 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 Sun Mar 13 09:47:18 2016
@@ -90,6 +90,7 @@ import org.codehaus.plexus.util.FileUtil
 import org.codehaus.plexus.util.PropertyUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.WriterFactory;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 import aQute.bnd.header.Attrs;
 import aQute.bnd.header.OSGiHeader;
@@ -313,6 +314,9 @@ public class BundlePlugin extends Abstra
     @Parameter( defaultValue = "${session}", readonly = true, required = true )
     private MavenSession m_mavenSession;
 
+    @Component
+    protected BuildContext buildContext;
+    
     private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
     private static final String MAVEN_RESOURCES = "{maven-resources}";
     private static final String MAVEN_TEST_RESOURCES = 
"{maven-test-resources}";
@@ -519,7 +523,7 @@ public class BundlePlugin extends Abstra
 
                 try
                 {
-                    ManifestPlugin.writeManifest( builder, outputFile, 
niceManifest, exportScr, scrLocation );
+                    ManifestPlugin.writeManifest( builder, outputFile, 
niceManifest, exportScr, scrLocation, buildContext );
                 }
                 catch ( IOException e )
                 {

Modified: 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java?rev=1734773&r1=1734772&r2=1734773&view=diff
==============================================================================
--- 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
 (original)
+++ 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
 Sun Mar 13 09:47:18 2016
@@ -22,7 +22,6 @@ package org.apache.felix.bundleplugin;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -33,23 +32,25 @@ import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.jar.Manifest;
 
-import aQute.bnd.header.Parameters;
-import aQute.bnd.osgi.Instructions;
-import aQute.bnd.osgi.Processor;
-import aQute.lib.collections.ExtList;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
+import aQute.bnd.header.Parameters;
 import aQute.bnd.osgi.Analyzer;
 import aQute.bnd.osgi.Builder;
+import aQute.bnd.osgi.Instructions;
 import aQute.bnd.osgi.Jar;
+import aQute.bnd.osgi.Processor;
 import aQute.bnd.osgi.Resource;
-import org.apache.maven.shared.dependency.graph.DependencyNode;
+import aQute.lib.collections.ExtList;
 
 
 /**
@@ -66,6 +67,9 @@ public class ManifestPlugin extends Bund
     @Parameter( property = "rebuildBundle" )
     protected boolean rebuildBundle;
 
+    @Component
+    private BuildContext buildContext;
+    
     @Override
     protected void execute( MavenProject project, DependencyNode 
dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] 
classpath )
         throws MojoExecutionException
@@ -99,7 +103,7 @@ public class ManifestPlugin extends Bund
 
         try
         {
-            writeManifest( analyzer, outputFile, niceManifest, exportScr, 
scrLocation );
+            writeManifest( analyzer, outputFile, niceManifest, exportScr, 
scrLocation, buildContext );
         }
         catch ( Exception e )
         {
@@ -122,12 +126,12 @@ public class ManifestPlugin extends Bund
     public Manifest getManifest( MavenProject project, DependencyNode 
dependencyGraph, Jar[] classpath ) throws IOException, MojoFailureException,
         MojoExecutionException, Exception
     {
-        return getManifest( project, dependencyGraph, new 
LinkedHashMap<String, String>(), new Properties(), classpath );
+        return getManifest( project, dependencyGraph, new 
LinkedHashMap<String, String>(), new Properties(), classpath, buildContext );
     }
 
 
-    public Manifest getManifest( MavenProject project, DependencyNode 
dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] 
classpath )
-        throws IOException, MojoFailureException, MojoExecutionException, 
Exception
+    public Manifest getManifest( MavenProject project, DependencyNode 
dependencyGraph, Map<String, String> instructions, Properties properties, Jar[] 
classpath,
+            BuildContext buildContext) throws IOException, 
MojoFailureException, MojoExecutionException, Exception
     {
         Analyzer analyzer = getAnalyzer(project, dependencyGraph, 
instructions, properties, classpath);
 
@@ -136,7 +140,7 @@ public class ManifestPlugin extends Bund
 
         if (exportScr)
         {
-            exportScr(analyzer, jar, scrLocation);
+            exportScr(analyzer, jar, scrLocation, buildContext);
         }
 
         // cleanup...
@@ -145,7 +149,7 @@ public class ManifestPlugin extends Bund
         return manifest;
     }
     
-    private static void exportScr(Analyzer analyzer, Jar jar, File 
scrLocation) throws Exception {
+    private static void exportScr(Analyzer analyzer, Jar jar, File 
scrLocation, BuildContext buildContext) throws Exception {
         scrLocation.mkdirs();
 
         String bpHeader = analyzer.getProperty(Analyzer.SERVICE_COMPONENT);
@@ -159,7 +163,7 @@ public class ManifestPlugin extends Bund
                 Resource resource = jar.getResource(root);
                 if (resource != null)
                 {
-                    writeSCR(resource, location);
+                    writeSCR(resource, location, buildContext);
                 }
             }
             else
@@ -168,16 +172,16 @@ public class ManifestPlugin extends Bund
                 {
                     String path = entry.getKey();
                     Resource resource = entry.getValue();
-                    writeSCR(resource, new File(location, path));
+                    writeSCR(resource, new File(location, path), buildContext);
                 }
             }
         }
     }
 
-    private static void writeSCR(Resource resource, File destination) throws 
Exception
+    private static void writeSCR(Resource resource, File destination, 
BuildContext buildContext) throws Exception
     {
         destination.getParentFile().mkdirs();
-        OutputStream os = new FileOutputStream(destination);
+        OutputStream os = buildContext.newFileOutputStream(destination);
         try
         {
             resource.write(os);
@@ -275,7 +279,7 @@ public class ManifestPlugin extends Bund
                 if ( !entryFile.exists() || entry.getValue().lastModified() == 
0 )
                 {
                     entryFile.getParentFile().mkdirs();
-                    OutputStream os = new FileOutputStream( entryFile );
+                    OutputStream os = buildContext.newFileOutputStream( 
entryFile );
                     entry.getValue().write( os );
                     os.close();
                 }
@@ -287,7 +291,7 @@ public class ManifestPlugin extends Bund
 
 
     public static void writeManifest( Analyzer analyzer, File outputFile, 
boolean niceManifest,
-            boolean exportScr, File scrLocation ) throws Exception
+            boolean exportScr, File scrLocation, BuildContext buildContext ) 
throws Exception
     {
         Properties properties = analyzer.getProperties();
         Jar jar = analyzer.getJar();
@@ -313,21 +317,21 @@ public class ManifestPlugin extends Bund
             File parentFile = outputFile.getParentFile();
             parentFile.mkdirs();
         }
-        writeManifest( manifest, outputFile, niceManifest );
+        writeManifest( manifest, outputFile, niceManifest, buildContext );
         
         if (exportScr)
         {
-            exportScr(analyzer, jar, scrLocation);            
+            exportScr(analyzer, jar, scrLocation, buildContext);            
         }
     }
 
 
-    public static void writeManifest( Manifest manifest, File outputFile, 
boolean niceManifest ) throws IOException
+    public static void writeManifest( Manifest manifest, File outputFile, 
boolean niceManifest,
+            BuildContext buildContext ) throws IOException
     {
         outputFile.getParentFile().mkdirs();
 
-        FileOutputStream os;
-        os = new FileOutputStream( outputFile );
+        OutputStream os = buildContext.newFileOutputStream( outputFile );
         try
         {
             ManifestWriter.outputManifest( manifest, os, niceManifest );

Modified: 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java?rev=1734773&r1=1734772&r2=1734773&view=diff
==============================================================================
--- 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
 (original)
+++ 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/AbstractBaselinePlugin.java
 Sun Mar 13 09:47:18 2016
@@ -47,6 +47,7 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 import aQute.bnd.differ.Baseline;
 import aQute.bnd.differ.Baseline.Info;
@@ -148,6 +149,9 @@ abstract class AbstractBaselinePlugin
     @Parameter
     protected List<String> supportedProjectTypes = Arrays.asList( new String[] 
{ "jar", "bundle" } );
 
+    @Component
+    protected BuildContext buildContext;
+    
     public final void execute()
         throws MojoExecutionException, MojoFailureException
     {

Modified: 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java?rev=1734773&r1=1734772&r2=1734773&view=diff
==============================================================================
--- 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java
 (original)
+++ 
felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/baseline/BaselineReport.java
 Sun Mar 13 09:47:18 2016
@@ -19,7 +19,6 @@
 package org.apache.felix.bundleplugin.baseline;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -100,7 +99,7 @@ public final class BaselineReport
 
             try
             {
-                target = new FileOutputStream( targetFile );
+                target = buildContext.newFileOutputStream( targetFile );
                 IOUtil.copy( source, target );
             }
             catch ( IOException e )


Reply via email to