You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2007/02/08 01:55:24 UTC

svn commit: r504758 - in /maven/sandbox/plugins/maven-bundle-plugin/src: main/java/org/apache/felix/tools/maven2/bundleplugin/ test/java/org/apache/felix/tools/maven2/bundleplugin/

Author: carlos
Date: Wed Feb  7 16:55:24 2007
New Revision: 504758

URL: http://svn.apache.org/viewvc?view=rev&rev=504758
Log:
Add classpathForExpansion option to allow converting jars to OSGi one to one

Modified:
    maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
    maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/RecursiveBundlePlugin.java
    maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java

Modified: maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java?view=diff&rev=504758&r1=504757&r2=504758
==============================================================================
--- maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java (original)
+++ maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/BundlePlugin.java Wed Feb  7 16:55:24 2007
@@ -106,8 +106,11 @@
     throw new MojoExecutionException("Error calculating classpath for project " + project, e);
   }
  }
-
  protected void execute(MavenProject project, Map instructions, Properties properties, Jar[] classpath) throws MojoExecutionException {
+  execute( project, instructions, properties, classpath, null );
+ }
+
+ protected void execute(MavenProject project, Map instructions, Properties properties, Jar[] classpath, Jar[] classpathForExpansion) throws MojoExecutionException {
   try {
    File jarFile = new File(getBuildDirectory(), getBundleName(project));
 
@@ -152,6 +155,7 @@
    builder.setBase(baseDir);
    builder.setProperties(properties);
    builder.setClasspath(classpath);
+   builder.setClasspathForExpansion(classpathForExpansion);
  
    builder.build();
    Jar jar = builder.getJar();

Modified: maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/RecursiveBundlePlugin.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/RecursiveBundlePlugin.java?view=diff&rev=504758&r1=504757&r2=504758
==============================================================================
--- maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/RecursiveBundlePlugin.java (original)
+++ maven/sandbox/plugins/maven-bundle-plugin/src/main/java/org/apache/felix/tools/maven2/bundleplugin/RecursiveBundlePlugin.java Wed Feb  7 16:55:24 2007
@@ -124,8 +124,6 @@
             throw new MojoExecutionException( "Unable to build dependency tree", e );
         }
 
-        System.out.println( dependencyTree );
-
         mapOfArtifacts = createMapOfArtifacts( project );
 
         for ( Iterator it = dependencyTree.inverseIterator(); it.hasNext(); )
@@ -155,7 +153,7 @@
         try
         {
             Map instructions = new HashMap();
-            instructions.put( Analyzer.EXPORT_PACKAGE, packagesAsString( getJar( artifact ) ) );
+            instructions.put( Analyzer.EXPORT_PACKAGE, "*" );
             execute( project, instructions, artifact );
         }
         catch ( IOException e )
@@ -168,7 +166,7 @@
         throws MojoExecutionException, IOException
     {
         Properties properties = new Properties();
-        execute( project, instructions, properties, getClasspath( this.project ) );
+        execute( project, instructions, properties, getClasspath( this.project ), new Jar[] { getJar( artifact ) } );
     }
 
     private Map createMapOfArtifacts( MavenProject project )

Modified: maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java?view=diff&rev=504758&r1=504757&r2=504758
==============================================================================
--- maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java (original)
+++ maven/sandbox/plugins/maven-bundle-plugin/src/test/java/org/apache/felix/tools/maven2/bundleplugin/BundlePluginTest.java Wed Feb  7 16:55:24 2007
@@ -20,10 +20,14 @@
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.util.List;
 
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
 
 import aQute.lib.osgi.Analyzer;
 import aQute.lib.osgi.Jar;
@@ -97,5 +101,37 @@
         builder.build();
 
         assertEquals( 3, builder.getExports().size() );
+    }
+
+    public void testGetPackages()
+        throws Exception
+    {
+        File jarFile = getTestFile( "target/test-jar.jar" );
+
+        createTestJar( jarFile );
+
+        Jar jar = new Jar( "testJar", jarFile );
+        List packages = plugin.getPackages( jar );
+
+        assertEquals( 4, packages.size() );
+        int i = 0;
+        assertEquals( "META-INF", packages.get( i++ ) );
+        assertEquals( "META-INF.maven.org.apache.maven.plugins.maven-bundle-plugin", packages.get( i++ ) );
+        assertEquals( "org.apache.maven.test", packages.get( i++ ) );
+        assertEquals( "org.apache.maven.test.resources", packages.get( i++ ) );
+    }
+
+    private void createTestJar( File jarFile )
+        throws ArchiverException, IOException
+    {
+        JarArchiver archiver = new JarArchiver();
+        archiver
+            .addFile( getTestFile( "target/classes/" + BundlePlugin.class.getName().replace( ".", "/" ) + ".class" ),
+                      "org/apache/maven/test/BundlePlugin.class" );
+        archiver.addFile( getTestFile( "pom.xml" ),
+                          "META-INF/maven/org.apache.maven.plugins/maven-bundle-plugin/pom.xml" );
+        archiver.addFile( getTestFile( "pom.xml" ), "org/apache/maven/test/resources/someresource" );
+        archiver.setDestFile( jarFile );
+        archiver.createArchive();
     }
 }