0

I am wrapping a bunch of JARs into a single OSGi bundle. There are oodles of packages, so I tries using org.apache.myfaces.* syntax. But then maven-bundle-plugin/bnd complains Exporting an empty package 'org.apache.myfaces.component'. Is there a convenient way how to export all non-empty packages without me having to actually inspect all of the packages?

Maven Bundle plugin configuration:

<configuration>
    <supportedProjectTypes>
        <supportedProjectType>jar</supportedProjectType>
    </supportedProjectTypes>
    <instructions>
        <Export-Package>
            javax.el,
            javax.servlet,
            javax.servlet.annotation,
            javax.servlet.descriptor,
            javax.servlet.http,
            javax.servlet.jsp,
            javax.servlet.jsp.el,
            javax.servlet.jsp.jstl.core,
            javax.servlet.jsp.jstl.fmt,
            javax.servlet.jsp.jstl.sql,
            javax.servlet.jsp.jstl.tlv,
            javax.servlet.jsp.resources,
            javax.servlet.jsp.tagext,
            javax.servlet.resources,
            org.apache.el,
            org.apache.el.lang,
            org.apache.el.parser,
            org.apache.el.stream,
            org.apache.el.util,
            org.apache.jasper,
            org.apache.jasper.compiler,
            org.apache.jasper.compiler.tagplugin,
            org.apache.jasper.el,
            org.apache.jasper.resources,
            org.apache.jasper.runtime,
            org.apache.jasper.security,
            org.apache.jasper.servlet,
            org.apache.jasper.tagplugins.jstl,
            org.apache.jasper.tagplugins.jstl.core,
            org.apache.jasper.util,
            org.apache.jasper.xmlparser,
            org.apache.juli.logging,
            !org.apache.myfaces.custom.dojo.resource.src.*,
            org.apache.myfaces.*,
            javax.faces.*,
            org.apache.taglibs.standard,
            org.apache.taglibs.standard.functions,
            org.apache.taglibs.standard.resources,
            org.apache.taglibs.standard.tag.common.core,
            org.apache.taglibs.standard.tag.common.fmt,
            org.apache.taglibs.standard.tag.common.sql,
            org.apache.taglibs.standard.tag.common.xml,
            org.apache.taglibs.standard.tag.rt.core,
            org.apache.taglibs.standard.tag.rt.fmt,
            org.apache.taglibs.standard.tag.rt.sql,
            org.apache.taglibs.standard.tag.rt.xml,
            org.apache.taglibs.standard.tei,
            org.apache.taglibs.standard.tlv,
            org.apache.taglibs.standard.util,
            org.apache.tomcat,
            org.apache.tomcat.util,
            org.apache.tomcat.util.buf,
            org.apache.tomcat.util.descriptor.tagplugin,
            org.apache.tomcat.util.descriptor.tld,
            org.apache.tomcat.util.descriptor.web,
            org.apache.tomcat.util.digester,
            org.apache.tomcat.util.file,
            org.apache.tomcat.util.res,
            org.apache.tomcat.util.scan,
            org.apache.tomcat.util.security,
            org.eclipse.jetty.annotations,
            org.eclipse.jetty.apache.jsp,
            org.eclipse.jetty.http,
            org.eclipse.jetty.http.pathmap,
            org.eclipse.jetty.io,
            org.eclipse.jetty.io.ssl,
            org.eclipse.jetty.jndi,
            org.eclipse.jetty.jndi.factories,
            org.eclipse.jetty.jndi.java,
            org.eclipse.jetty.jndi.local,
            org.eclipse.jetty.jsp,
            org.eclipse.jetty.plus.annotation,
            org.eclipse.jetty.plus.jndi,
            org.eclipse.jetty.plus.security,
            org.eclipse.jetty.plus.webapp,
            org.eclipse.jetty.security,
            org.eclipse.jetty.security.authentication,
            org.eclipse.jetty.server,
            org.eclipse.jetty.server.handler,
            org.eclipse.jetty.server.handler.gzip,
            org.eclipse.jetty.server.handler.jmx,
            org.eclipse.jetty.server.jmx,
            org.eclipse.jetty.server.nio,
            org.eclipse.jetty.server.session,
            org.eclipse.jetty.servlet,
            org.eclipse.jetty.servlet.jmx,
            org.eclipse.jetty.servlet.listener,
            org.eclipse.jetty.servlets,
            org.eclipse.jetty.util,
            org.eclipse.jetty.util.annotation,
            org.eclipse.jetty.util.component,
            org.eclipse.jetty.util.log,
            org.eclipse.jetty.util.preventers,
            org.eclipse.jetty.util.resource,
            org.eclipse.jetty.util.security,
            org.eclipse.jetty.util.ssl,
            org.eclipse.jetty.util.statistic,
            org.eclipse.jetty.util.thread,
            org.eclipse.jetty.util.thread.strategy,
            org.eclipse.jetty.webapp,
            org.eclipse.jetty.xml,
            org.objectweb.asm,
            org.objectweb.asm.**,
            org.slf4j,
            org.slf4j.**
        </Export-Package>
        <!-- /Export-Package -->
        <Import-Package>
            org.slf4j,
            org.slf4j.**,
            !*
        </Import-Package>
        <Manifest-Version>1.0</Manifest-Version>
        <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
        <Require-Bundle>javax.servlet;visibility:=reexport</Require-Bundle>
        <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment>
        <Bundle-Name>Jetty9 Plug-in</Bundle-Name>
        <Bundle-SymbolicName>org.mortbay.jetty</Bundle-SymbolicName>
        <Bundle-Version>${bundle.version}</Bundle-Version>
        <Bundle-Description>Jetty 9.x</Bundle-Description>
        <Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
        <!-- Embed-Dependency>*;scope=compile|runtime;optional=false</Embed-Dependency -->
        <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
        <Embed-Transitive>true</Embed-Transitive>
        <!-- Embed-StripGroup>false</Embed-StripGroup -->
        <!-- Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy -->
        <_noee>true</_noee>
        <!-- _nouses>true</_nouses -->
        <_check>ALL</_check>
        <_reproducible>true</_reproducible>
    </instructions>
</configuration>

This produces:

[INFO] --- maven-bundle-plugin:4.1.0:bundle (build-bundle) @ org.mortbay.jetty ---
[WARNING] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Import package org.slf4j.impl not found in any bundle on the -buildpath. List explicitly in Import-Package: p,* to get rid of this warning if false
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.application'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.application.jsp'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.application.pss'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.component'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.component.html.ext'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.component.html.util'
[ERROR] Bundle <groupId>:org.mortbay.jetty:jar:9.4.11-2 : Exporting an empty package 'org.apache.myfaces.config'
...
wilx
  • 17,697
  • 6
  • 59
  • 114
  • share your plugin config from pom.xml – awd Oct 26 '18 at 12:01
  • @awd: I have updated the question with more information. – wilx Oct 26 '18 at 14:11
  • remove the `<_check>ALL` instruction and it shoudl work. – awd Oct 26 '18 at 14:44
  • Why are you embedding all those dependencies into your own bundle, and exporting their packages? At least jetty-util (and probably others) are already packaged as OSGi bundles, and could be deployed to your container along with your own bundle. – gjoranv Oct 26 '18 at 15:17
  • @awd I want the checks and I want clean build. – wilx Oct 26 '18 at 19:57
  • @gjoranv This is historical, there is no way for me to change this. – wilx Oct 26 '18 at 19:58
  • Exporting empty packages should not do any harm, as no other bundle will have an Import-Package created for it (at least not by any decent bundle plugin). So I suggest to be more pragmatic about the checks, and setting it to `IMPORTS` instead of `ALL`. See also https://github.com/bndtools/bnd/blob/6e1af4c3c15bf4f12d9639193a2ab2cffb3bf95a/docs/_instructions/check.md – gjoranv Oct 26 '18 at 21:34

0 Answers0