It's always best to answer your own questions  ;-)

I found a way to make it work. It may not be the prettiest (especially the 
version issue), but here we go:

Below is part of my POM which defines the build.

The first plugin is my own which unpacks the all JARs to 'target/classes'.

The second plugin (Felix) generates the bundle manifest file and has to export 
everything. Since I know nothing about the versions (and JBoss cunningly hides 
them!), I just specify that it must be at least version 0.1 - I hope I got the 
syntax right!

The third plugin is the good ol' Maven JAR plugin, which doesn't generate a new 
MANIFEST.MF file, but takes the one generated by the Felix Bundle plugin.

  <build>
    <plugins>

      <!-- This acts like the compile plugin, because it unpacks the classes to 
target/classes -->
      <plugin>
        <groupId>ch.ipi</groupId>
        <artifactId>jboss-client</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>unpack-jars</goal>
            </goals>
            <configuration>
              <sourceJar>${jboss.home}/client/jbossall-client.jar</sourceJar>
              <workingDirectory>${working.directory}</workingDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>   
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <executions>
          <execution>
            <id>bundle-manifest</id>
            <phase>process-classes</phase>
            <goals>    
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Export-Package>*;version="0.1"</Export-Package>
              </instructions>
            </configuration>   
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <forceCreation>true</forceCreation>
              <classesDirectory>${working.directory}</classesDirectory>
              <useDefaultManifestFile>true</useDefaultManifestFile>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>
  
  <properties>
    <working.directory>${project.build.directory}/classes</working.directory>
  </properties> 


This works, even though it creates a huge (53K) MANIFEST.MF file.

Best regards,
Eric

> -----Ursprüngliche Nachricht-----
> Von: Lewis, Eric [mailto:[email protected]] 
> Gesendet: Dienstag, 21. April 2009 11:15
> An: [email protected]
> Betreff: AW: Create bundle from unpacked JARs
> 
> Hi Toni
> 
> No, they're not. Actually what I'm doing is to read JBoss's 
> jbossall-client.jar (from 5.0.1.GA) which only contains a 
> Classpath and then merge the whole classpath into one JAR.
> Perhaps there's a better way than what I'm trying to do...
> 
> Best regards,
> Eric 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: [email protected] 
> > [mailto:[email protected]] Im Auftrag von Toni Menzel
> > Gesendet: Dienstag, 21. April 2009 11:05
> > An: [email protected]
> > Betreff: Re: Create bundle from unpacked JARs
> > 
> > Are the other jars maven2 artifacts ?
> > If so, its very straightforward doing so by using the
> > embed-Dependency declaration and its friends.
> > 
> > Have a look here:
> > http://felix.apache.org/site/apache-felix-maven-bundle-plugin-
> > bnd.html(Search
> > for Embed Dependency)
> > If the jars are not maven artifacts yet, it might be 
> > worthwhile to do that
> > before.
> > 
> > Toni
> > 
> > On Tue, Apr 21, 2009 at 10:57 AM, Lewis, Eric 
> > <[email protected]> wrote:
> > 
> > > Hi
> > >
> > > I have a question regarding the Felix Maven plugin. I'm 
> using it and
> > > it's great, but I have a special problem here.
> > > I want to repack a number of JARs into one big JAR and make 
> > it an OSGi
> > > bundle. The Felix plugin takes the class directory from 
> > Maven's target
> > > directory (and can add dependencies etc.)  However I would 
> > just like to
> > > specify a directory where all classes to use in the bundle 
> > can be found.
> > >
> > > The Maven JAR plugin offers the 'classesDirectory' parameter, see
> > > 
> > http://maven.apache.org/plugins/maven-jar-plugin/jar-mojo.html
> > #classesDi
> > > rectory
> > >
> > > Is it possible to do the same with the Felix Maven plugin?
> > >
> > > Best regards,
> > > Eric
> > >
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> > >
> > 
> > 
> > -- 
> > Toni Menzel
> > Independent Software Developer - Looking for new projects!
> > Professional Profile: http://www.osgify.com
> > Blog: tonitcom.blogspot.com
> > [email protected]
> > http://www.ops4j.org     - New Energy for OSS Communities - Open
> > Participation Software.
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to