You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Bram de Kruijff <br...@gx.nl> on 2007/11/01 15:49:36 UTC

bundle plugin question

Hello all,

trying to migrate from the maven-osgi-plugin (that was deprecated.....
;)) to the maven-bundle-plugin I got stuck with our XML parser 'wrapper'
bundle. Can anyone give a hint how to configure this with the new
plugin?


The maven-osgi-plugin configuration below worked like a charm resulting
in a 2k bundle with no classes and just the two javax.xml.parsers.*
provider configuration files we put in the META-INF/services. At runtime
it registers the services as expected.

Now using the maven-bundle-plugin I get a build-time 'Bundle-Activator
not found on the bundle class path or imports'. Note that in both
situations the org.osgi.compendium is on the build classpath with a
provided scope. When changing this to a compile scope the build actually
succeeds but also results in inclusion of the compendium classes :(

So how can I convince the bundle plugin that the activator actually is
on the classpath and that the classes shouldn't included but imported?

thank you!
best regards,
Bram

--------------------------------
maven-osgi-plugin configuration
--------------------------------

in the pom...

            <plugin>
                <groupId>org.apache.felix.plugins</groupId>
                <artifactId>maven-osgi-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <osgiManifest>
 
<bundleActivator>org.osgi.util.xml.XMLParserActivator</bundleActivator>
                        <bundleName>XML Parser</bundleName>
                        <importPackage>javax.xml.parsers,
org.osgi.framework, org.osgi.util.xml</importPackage>
                        <exportPackage />
                    </osgiManifest>
                </configuration>
            </plugin>


in the manifest...

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: bramk
Build-Jdk: 1.5.0_12
Bundle-Activator: org.osgi.util.xml.XMLParserActivator
Bundle-Version: 9.2.2.SNAPSHOT
Bundle-ManifestVersion: 2
Bundle-Vendor: GX Creative Online Development
Import-Package: javax.xml.parsers,org.osgi.framework,org.osgi.util.xml
Bundle-Name: GX WebManager XML Parser
Bundle-Classpath: .
Bundle-SymbolicName: nl.gx.webmanager.bundles.webmanager-xmlparser-bun
 dle



--------------------------------
maven-bundle-plugin configuration
--------------------------------

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
 
<Bundle-Activator>org.osgi.util.xml.XMLParserActivator</Bundle-Activator
>
                        <Bundle-Name>XML Parser</Bundle-Name>
                        <Import-Package>javax.xml.parsers,
org.osgi.framework, org.osgi.util.xml</Import-Package>
                        <Export-Package />
                    </instructions>
                </configuration>
            </plugin>


[ERROR] Bundle-Activator not found on the bundle class path or imports:
org.osgi.util.xml.XMLParserActivator
org.apache.maven.plugin.MojoFailureException: Found errors, see log
        at
org.apache.felix.tools.maven2.bundleplugin.BundlePlugin.execute(BundlePl
ugin.java:153)



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: bundle plugin question

Posted by Bram de Kruijff <br...@gx.nl>.
> looking at the error message, I believe this is due a bug in 
> Bnd which was fixed after the 1.0.0 release (it ignored 
> bundle activators that were imported, not actually in the 
> finished bundle)
> - this bug has been fixed and is available in the current 
> 1.1.0-SNAPSHOT


Works for me. Thank you very much for your response!

regards,
Bram



> -----Original Message-----
> From: mcculls@gmail.com [mailto:mcculls@gmail.com] On Behalf 
> Of Stuart McCulloch
> Sent: Thursday, November 01, 2007 5:29 PM
> To: users@felix.apache.org
> Subject: Re: bundle plugin question
> 
> On 01/11/2007, Bram de Kruijff <br...@gx.nl> wrote:
> >
> > Hello all,
> >
> > trying to migrate from the maven-osgi-plugin (that was 
> deprecated.....
> > ;)) to the maven-bundle-plugin I got stuck with our XML 
> parser 'wrapper'
> > bundle. Can anyone give a hint how to configure this with the new 
> > plugin?
> >
> >
> > The maven-osgi-plugin configuration below worked like a charm 
> > resulting in a 2k bundle with no classes and just the two 
> > javax.xml.parsers.* provider configuration files we put in the 
> > META-INF/services. At runtime it registers the services as expected.
> >
> > Now using the maven-bundle-plugin I get a build-time 
> 'Bundle-Activator 
> > not found on the bundle class path or imports'. Note that in both 
> > situations the org.osgi.compendium is on the build classpath with a 
> > provided scope. When changing this to a compile scope the build 
> > actually succeeds but also results in inclusion of the compendium 
> > classes :(
> 
> 
> quick note here - provided scope dependencies are not added 
> to the Bnd tool classpath because the bundle mojo has 
> "@requiresDependencyResolution runtime" (I'm not 100% sure 
> why this was chosen - its been like that for a while - but it 
> does mean that you won't accidentally pull in classes from 
> other bundles, as they're typically marked as "provided")
> 
> So how can I convince the bundle plugin that the activator actually is
> > on the classpath and that the classes shouldn't included 
> but imported?
> 
> 
> a bit of background to Bnd, which does most of the work underneath the
> bundle-plugin:
> 
> as explained on Peter Kriens' page at 
> http://www.aqute.biz/Code/Bnd, and in examples from the 
> bundle-plugin docs 
> http://felix.apache.org/site/maven-bundle-plugin-bnd.html,
> the Bnd tool uses the Export-Package, Private-Package and 
> Include-Resource directives to decide the contents of the 
> bundle (ie. what classes and resources to _pull_ in)
> 
> most of the time you won't need to set Import-Package (which 
> defaults to *) as Bnd will expand this to the set of packages 
> your bundle actually uses. You really only need to set it 
> when you need to tweak the discovered imports to mark some as 
> optional, or to set a version range, etc. - or in your case 
> where you're not actually including any classes.
> 
> so the Bnd tool won't jar up everything under target/classes, 
> or everything on the classpath
> - only what you specify in Export-Package, Private-Package 
> and Include-Resource - this can be very powerful, as it means 
> you can easily split a large project into several bundles.
> 
> ( the bundle-plugin will automatically add Maven resources 
> for you using Include-Resource )
> 
> anyway, see below for more about your particular scenario...
> 
> thank you!
> > best regards,
> > Bram
> >
> > --------------------------------
> > maven-osgi-plugin configuration
> > --------------------------------
> >
> > in the pom...
> >
> >             <plugin>
> >                 <groupId>org.apache.felix.plugins</groupId>
> >                 <artifactId>maven-osgi-plugin</artifactId>
> >                 <extensions>true</extensions>
> >                 <configuration>
> >                     <osgiManifest>
> >
> > 
> <bundleActivator>org.osgi.util.xml.XMLParserActivator</bundleA
ctivator>
> >                         <bundleName>XML Parser</bundleName>
> >                         <importPackage>javax.xml.parsers, 
> > org.osgi.framework, org.osgi.util.xml</importPackage>
> >                         <exportPackage />
> >                     </osgiManifest>
> >                 </configuration>
> >             </plugin>
> >
> >
> > in the manifest...
> >
> > Manifest-Version: 1.0
> > Archiver-Version: Plexus Archiver
> > Created-By: Apache Maven
> > Built-By: bramk
> > Build-Jdk: 1.5.0_12
> > Bundle-Activator: org.osgi.util.xml.XMLParserActivator
> > Bundle-Version: 9.2.2.SNAPSHOT
> > Bundle-ManifestVersion: 2
> > Bundle-Vendor: GX Creative Online Development
> > Import-Package: 
> javax.xml.parsers,org.osgi.framework,org.osgi.util.xml
> > Bundle-Name: GX WebManager XML Parser
> > Bundle-Classpath: .
> > Bundle-SymbolicName: 
> nl.gx.webmanager.bundles.webmanager-xmlparser-bun
> > dle
> >
> >
> >
> > --------------------------------
> > maven-bundle-plugin configuration
> > --------------------------------
> >
> >             <plugin>
> >                 <groupId>org.apache.felix</groupId>
> >                 <artifactId>maven-bundle-plugin</artifactId>
> >                 <extensions>true</extensions>
> >                 <configuration>
> >                     <instructions>
> >
> > 
> <Bundle-Activator>org.osgi.util.xml.XMLParserActivator</Bundle-Activat
> > or
> > >
> >                         <Bundle-Name>XML Parser</Bundle-Name>
> >                         <Import-Package>javax.xml.parsers,
> > org.osgi.framework, org.osgi.util.xml</Import-Package>
> >                         <Export-Package />
> >                     </instructions>
> >                 </configuration>
> >             </plugin>
> >
> >
> > [ERROR] Bundle-Activator not found on the bundle class path 
> or imports:
> > org.osgi.util.xml.XMLParserActivator
> > org.apache.maven.plugin.MojoFailureException: Found errors, see log
> >         at
> > 
> org.apache.felix.tools.maven2.bundleplugin.BundlePlugin.execute(Bundle
> > Pl
> > ugin.java:153)
> 
> 
> looking at the error message, I believe this is due a bug in 
> Bnd which was fixed after the 1.0.0 release (it ignored 
> bundle activators that were imported, not actually in the 
> finished bundle)
> - this bug has been fixed and is available in the current 
> 1.1.0-SNAPSHOT
> 
> ( FYI, you can use 
> "http://repository.ops4j.org/mvn-snapshots" if you want to 
> try this snapshot
>   without also pulling in all the other snapshots of various 
> maven plugins that are in the main
>   snapshot repository at apache... )
> 
> I tried these instructions with the 1.1.0-SNAPSHOT and I get 
> a bundle with the right resources and the necessary imports - 
> note you will see a warning about there being no packages in 
> the final bundle, but the build will succeed. Also changing 
> the compendium to compile scope didn't add any extra classes 
> to the bundle.
> 
> HTH - if you find any missing features or outstanding bugs, 
> file them at JIRA and I'll take a look
> 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
> 
> 
> --
> Cheers, Stuart
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: bundle plugin question

Posted by Stuart McCulloch <st...@jayway.net>.
On 01/11/2007, Bram de Kruijff <br...@gx.nl> wrote:
>
> Hello all,
>
> trying to migrate from the maven-osgi-plugin (that was deprecated.....
> ;)) to the maven-bundle-plugin I got stuck with our XML parser 'wrapper'
> bundle. Can anyone give a hint how to configure this with the new
> plugin?
>
>
> The maven-osgi-plugin configuration below worked like a charm resulting
> in a 2k bundle with no classes and just the two javax.xml.parsers.*
> provider configuration files we put in the META-INF/services. At runtime
> it registers the services as expected.
>
> Now using the maven-bundle-plugin I get a build-time 'Bundle-Activator
> not found on the bundle class path or imports'. Note that in both
> situations the org.osgi.compendium is on the build classpath with a
> provided scope. When changing this to a compile scope the build actually
> succeeds but also results in inclusion of the compendium classes :(


quick note here - provided scope dependencies are not added to the Bnd tool
classpath
because the bundle mojo has "@requiresDependencyResolution runtime" (I'm not
100%
sure why this was chosen - its been like that for a while - but it does mean
that you won't
accidentally pull in classes from other bundles, as they're typically marked
as "provided")

So how can I convince the bundle plugin that the activator actually is
> on the classpath and that the classes shouldn't included but imported?


a bit of background to Bnd, which does most of the work underneath the
bundle-plugin:

as explained on Peter Kriens' page at http://www.aqute.biz/Code/Bnd, and in
examples
from the bundle-plugin docs
http://felix.apache.org/site/maven-bundle-plugin-bnd.html,
the Bnd tool uses the Export-Package, Private-Package and Include-Resource
directives
to decide the contents of the bundle (ie. what classes and resources to
_pull_ in)

most of the time you won't need to set Import-Package (which defaults to *)
as Bnd will
expand this to the set of packages your bundle actually uses. You really
only need to set
it when you need to tweak the discovered imports to mark some as optional,
or to set a
version range, etc. - or in your case where you're not actually including
any classes.

so the Bnd tool won't jar up everything under target/classes, or everything
on the classpath
- only what you specify in Export-Package, Private-Package and
Include-Resource - this can
be very powerful, as it means you can easily split a large project into
several bundles.

( the bundle-plugin will automatically add Maven resources for you using
Include-Resource )

anyway, see below for more about your particular scenario...

thank you!
> best regards,
> Bram
>
> --------------------------------
> maven-osgi-plugin configuration
> --------------------------------
>
> in the pom...
>
>             <plugin>
>                 <groupId>org.apache.felix.plugins</groupId>
>                 <artifactId>maven-osgi-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <osgiManifest>
>
> <bundleActivator>org.osgi.util.xml.XMLParserActivator</bundleActivator>
>                         <bundleName>XML Parser</bundleName>
>                         <importPackage>javax.xml.parsers,
> org.osgi.framework, org.osgi.util.xml</importPackage>
>                         <exportPackage />
>                     </osgiManifest>
>                 </configuration>
>             </plugin>
>
>
> in the manifest...
>
> Manifest-Version: 1.0
> Archiver-Version: Plexus Archiver
> Created-By: Apache Maven
> Built-By: bramk
> Build-Jdk: 1.5.0_12
> Bundle-Activator: org.osgi.util.xml.XMLParserActivator
> Bundle-Version: 9.2.2.SNAPSHOT
> Bundle-ManifestVersion: 2
> Bundle-Vendor: GX Creative Online Development
> Import-Package: javax.xml.parsers,org.osgi.framework,org.osgi.util.xml
> Bundle-Name: GX WebManager XML Parser
> Bundle-Classpath: .
> Bundle-SymbolicName: nl.gx.webmanager.bundles.webmanager-xmlparser-bun
> dle
>
>
>
> --------------------------------
> maven-bundle-plugin configuration
> --------------------------------
>
>             <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <instructions>
>
> <Bundle-Activator>org.osgi.util.xml.XMLParserActivator</Bundle-Activator
> >
>                         <Bundle-Name>XML Parser</Bundle-Name>
>                         <Import-Package>javax.xml.parsers,
> org.osgi.framework, org.osgi.util.xml</Import-Package>
>                         <Export-Package />
>                     </instructions>
>                 </configuration>
>             </plugin>
>
>
> [ERROR] Bundle-Activator not found on the bundle class path or imports:
> org.osgi.util.xml.XMLParserActivator
> org.apache.maven.plugin.MojoFailureException: Found errors, see log
>         at
> org.apache.felix.tools.maven2.bundleplugin.BundlePlugin.execute(BundlePl
> ugin.java:153)


looking at the error message, I believe this is due a bug in Bnd which was
fixed after the 1.0.0
release (it ignored bundle activators that were imported, not actually in
the finished bundle)
- this bug has been fixed and is available in the current 1.1.0-SNAPSHOT

( FYI, you can use "http://repository.ops4j.org/mvn-snapshots" if you want
to try this snapshot
  without also pulling in all the other snapshots of various maven plugins
that are in the main
  snapshot repository at apache... )

I tried these instructions with the 1.1.0-SNAPSHOT and I get a bundle with
the right resources
and the necessary imports - note you will see a warning about there being no
packages in the
final bundle, but the build will succeed. Also changing the compendium to
compile scope didn't
add any extra classes to the bundle.

HTH - if you find any missing features or outstanding bugs, file them at
JIRA and I'll take a look

---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart