You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Aaron Zeckoski <aa...@vt.edu> on 2009/04/13 11:59:05 UTC

maven-bundle-plugin: properly handling logging?

I am trying to ensure my bundle is not going to fail because the
commons stuff I am using (httpclient) requires JCL. I don't use it
myself but if it is not there then things just fail so I have to
include it in my bundle. I would prefer to have the bundle work even
if the OSGi it is deployed into has no logging service so I set it up
to export JCL and log4j and also import them. Does this seem like an
OK way to handle things?
Any pointers would be appreciated. Thanks!

>From the pom (attached):
    <!-- logging -->
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>

<Bundle-Activator>org.sakaiproject.eb.osgi.EBActivator</Bundle-Activator>

<Export-Package>!org.sakaiproject.entitybus.impl.*,!org.sakaiproject.entitybus.util.*,org.sakaiproject.entitybus.*,org.sakaiproject.eb.osgi.util.*,org.apache.commons.logging,org.apache.log4j,</Export-Package>

<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                    <!-- logging adds
!org.apache.log,!org.apache.avalon.*,!com.sun.*,!org.w3c.dom, -->

<Import-Package>!org.apache.commons.beanutils.*,!javax.*,!org.xml.*,!org.apache.log,!org.apache.avalon.*,!com.sun.*,!org.w3c.dom,,org.apache.commons.logging,org.apache.log4j,*</Import-Package>
                </instructions>
            </configuration>
        </plugin>

And then the mannifest looks sorta like this:
Import-Package: org.apache.commons.logging,org.apache.log4j,org.osgi.f
 ramework;version="1.3",org.osgi.util.tracker;version="1.3",org.sakaip
...(snip)
Embed-Transitive: true
Bnd-LastModified: 1239616629144
Export-Package: org.sakaiproject.entitybus.entityprovider.extension;us
 es:="org.sakaiproject.entitybus,org.sakaiproject.entitybus.entityprov
...(snip)
 us.providers",org.sakaiproject.entitybus.event,org.sakaiproject.eb.os
 gi.util;uses:="org.osgi.framework,org.osgi.util.tracker",org.apache.c
 ommons.logging,org.apache.log4j
Bundle-Version: 0.9.0.SNAPSHOT
Ignore-Package: org.apache.commons.beanutils,javax.swing.text,org.xml.
...(snip)
Bundle-Name: EntityBroker OSGi Services
Bundle-ClassPath: .,commons-logging-1.1.1.jar,reflectutils-0.9.10.jar,
 entitybus-impl-1.0.3.jar,commons-httpclient-3.1.jar,servlet-api-2.4.j
 ar,entitybus-api-1.0.3.jar,commons-codec-1.2.jar,log4j-1.2.14.jar,ent
 itybus-utils-1.0.3.jar

-AZ


-- 
Aaron Zeckoski (aaronz@vt.edu)
Senior Research Engineer - CARET - Cambridge University
[http://bugs.sakaiproject.org/confluence/display/~aaronz/]
Sakai Fellow - [http://aaronz-sakai.blogspot.com/]