You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2007/06/14 14:31:52 UTC

svn commit: r547231 - in /felix/trunk/bundleplugin/src: main/java/org/apache/felix/bundleplugin/ test/java/org/apache/felix/bundleplugin/

Author: rickhall
Date: Thu Jun 14 05:31:48 2007
New Revision: 547231

URL: http://svn.apache.org/viewvc?view=rev&rev=547231
Log:
Applied patch (FELIX-305) to allow the output folder to be configured.

Modified:
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
    felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java?view=diff&rev=547231&r1=547230&r2=547231
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundleAllPlugin.java Thu Jun 14 05:31:48 2007
@@ -52,6 +52,7 @@
 import aQute.lib.osgi.Jar;
 
 /**
+ * Create OSGi bundles from all dependencies in the Maven project
  * 
  * @goal bundleall
  * @phase package
@@ -282,7 +283,7 @@
                 osgiJar.setManifest( manifest );
             }
 
-            outputFile.getParentFile().mkdirs();
+            outputFile.getAbsoluteFile().getParentFile().mkdirs();
             osgiJar.write( outputFile );
 
             BundleInfo bundleInfo = addExportedPackages( project, exportedPackages );
@@ -428,7 +429,7 @@
 
     protected File getOutputFile( Artifact artifact )
     {
-        return new File( getBuildDirectory(), getBundleName( artifact ) );
+        return new File( getOutputDirectory(), getBundleName( artifact ) );
     }
 
     private Artifact resolveArtifact( Artifact artifact )

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?view=diff&rev=547231&r1=547230&r2=547231
==============================================================================
--- 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 Thu Jun 14 05:31:48 2007
@@ -21,18 +21,18 @@
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
-import java.util.regex.*;
 import java.util.zip.ZipException;
- 
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.*;
 import org.apache.maven.plugin.*;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
- 
+
 import aQute.lib.osgi.*;
  
 /**
+ * Create an OSGi bundle from Maven project
  * 
  * @goal bundle
  * @phase package
@@ -40,15 +40,16 @@
  * @description build an OSGi bundle jar
  */
 public class BundlePlugin extends AbstractMojo {
- 
+
  private static final Collection SUPPORTED_PROJECT_TYPES = Arrays.asList(new String[]{"jar","bundle"});
 
  /**
+  * The directory for the generated bundles.
+  * 
   * @parameter expression="${project.build.outputDirectory}"
   * @required
-  * @readonly
   */
- File     outputDirectory;
+ private File outputDirectory;
  
  /**
   * The directory for the pom
@@ -82,12 +83,19 @@
   */
  private Map    instructions = new HashMap();
 
- private Maven2OsgiConverter maven2OsgiConverter = new Maven2OsgiConverter();
+ /**
+  * @component
+  */
+ private Maven2OsgiConverter maven2OsgiConverter;
 
  protected Maven2OsgiConverter getMaven2OsgiConverter() {
   return maven2OsgiConverter;
  }
 
+ void setMaven2OsgiConverter(Maven2OsgiConverter maven2OsgiConverter) {
+  this.maven2OsgiConverter = maven2OsgiConverter;
+ }
+
  protected MavenProject getProject() {
   return project;
  }
@@ -264,8 +272,8 @@
  protected Jar[] getClasspath(MavenProject project) throws ZipException, IOException {
   List list = new ArrayList();
   
-  if (outputDirectory != null && outputDirectory.exists()) {
-    list.add(new Jar(".", outputDirectory));
+  if (getOutputDirectory() != null && getOutputDirectory().exists()) {
+    list.add(new Jar(".", getOutputDirectory()));
   }
  
   Set artifacts = project.getDependencyArtifacts();
@@ -382,13 +390,17 @@
      properties.putAll( getProperies(project.getModel(), "project.", project));
      properties.put("project.baseDir", baseDir );
      properties.put("project.build.directory", getBuildDirectory() );
-     properties.put("project.build.outputdirectory", outputDirectory );
+     properties.put("project.build.outputdirectory", getOutputDirectory() );
      
      return properties;
  }
  
  void setBasedir(File basedir){
      this.baseDir = basedir;
+ }
+
+ File getOutputDirectory(){
+     return this.outputDirectory;
  }
 
  void setOutputDirectory(File outputDirectory){

Modified: felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java?view=diff&rev=547231&r1=547230&r2=547231
==============================================================================
--- felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java (original)
+++ felix/trunk/bundleplugin/src/test/java/org/apache/felix/bundleplugin/BundleAllPluginTest.java Thu Jun 14 05:31:48 2007
@@ -28,6 +28,7 @@
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 
 /**
  * Test for {@link BundleAllPlugin}
@@ -57,6 +58,7 @@
         plugin.setBuildDirectory( buildDirectory.getPath() );
         File outputDirectory = new File( buildDirectory, "classes" );
         plugin.setOutputDirectory( outputDirectory );
+        plugin.setMaven2OsgiConverter( new DefaultMaven2OsgiConverter() );
     }
 
     public void testSnapshotMatch()

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?view=diff&rev=547231&r1=547230&r2=547231
==============================================================================
--- 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 Thu Jun 14 05:31:48 2007
@@ -28,6 +28,7 @@
 
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 
@@ -51,6 +52,7 @@
     {
         super.setUp();
         plugin = new BundlePlugin();
+        plugin.setMaven2OsgiConverter( new DefaultMaven2OsgiConverter() );
     }
 
     public void testConvertVersionToOsgi()