Velocity
  1. Velocity
  2. VELOCITY-768

Mark optional dependencies as optional in OSGi bundle manifest

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.x
    • Fix Version/s: 1.7
    • Component/s: Build
    • Labels:
      None

      Description

      Trying to use the Velocity 1.7-beta1 JAR in our OSGi container (Felix running in Atlassian Confluence), we ran into dependency problems because all the dependencies of Velocity are marked as mandatory.

      As you would know, Velocity has a logging abstraction which allows different logging frameworks to be used. Likewise, you don't need the servlet API to use Velocity. However, these dependencies are marked as required in the new OSGi manifest added in VELOCITY-694. This causes the bundle to fail to start because the dependencies are missing.

      From our testing, we could use Velocity in our application just fine with following imports changed to be optional:

      • com.werken.xpath
      • javax.servlet
      • javax.servlet.http
      • org.apache.commons.logging
      • org.apache.log
      • org.apache.log.format
      • org.apache.log.output.io
      • org.apache.log4j
      • org.apache.oro.text.perl
      • org.apache.tools.ant
      • org.apache.tools.ant.taskdefs
      • org.jdom
      • org.jdom.input
      • org.jdom.output

      That means changing the current Import-Package declaration from this:

      Import-Package: com.werken.xpath,
      javax.naming,
      javax.servlet,
      javax.servlet.http,
      javax.sql,
      org.apache.commons.collections,
      org.apache.commons.collections.map,
      org.apache.commons.lang,
      org.apache.commons.lang.builder,
      org.apache.commons.lang.text,
      org.apache.commons.logging,
      org.apache.log,
      org.apache.log.format,
      org.apache.log.output.io,
      org.apache.log4j,
      org.apache.oro.text.perl,
      org.apache.tools.ant,
      org.apache.tools.ant.taskdefs,
      org.jdom,
      org.jdom.input,
      org.jdom.output,
      org.xml.sax

      to this:

      Import-Package: com.werken.xpath;resolution:=optional,
      javax.naming,
      javax.servlet;resolution:=optional,
      javax.servlet.http;resolution:=optional,
      javax.sql,
      org.apache.commons.collections,
      org.apache.commons.collections.map,
      org.apache.commons.lang,
      org.apache.commons.lang.builder,
      org.apache.commons.lang.text,
      org.apache.commons.logging;resolution:=optional,
      org.apache.log;resolution:=optional,
      org.apache.log.format;resolution:=optional,
      org.apache.log.output.io;resolution:=optional,
      org.apache.log4j;resolution:=optional,
      org.apache.oro.text.perl;resolution:=optional,
      org.apache.tools.ant;resolution:=optional,
      org.apache.tools.ant.taskdefs;resolution:=optional,
      org.jdom;resolution:=optional,
      org.jdom.input;resolution:=optional,
      org.jdom.output;resolution:=optional,
      org.xml.sax

      I'll prepare a patch against trunk and attach it shortly.

        Issue Links

          Activity

          Hide
          Matt Ryall added a comment -

          Patch attached. I've also cleaned up the dependencies list a bit by splitting them onto separate lines.

          If you move to building Velocity releases with Maven, it might be worth considering using the BND Maven plugin for generating this information from the POM, rather than duplicating the dependency information in build.properties.

          Show
          Matt Ryall added a comment - Patch attached. I've also cleaned up the dependencies list a bit by splitting them onto separate lines. If you move to building Velocity releases with Maven, it might be worth considering using the BND Maven plugin for generating this information from the POM, rather than duplicating the dependency information in build.properties.
          Hide
          Nathan Bubna added a comment -

          Thanks, i've applied the patch. I'm still a newbie when it comes to OSGi, so help is welcome. As for generating from the POM, can the POM express "required-for-compilation-but-optional-for-users"? I didn't think it could...

          Show
          Nathan Bubna added a comment - Thanks, i've applied the patch. I'm still a newbie when it comes to OSGi, so help is welcome. As for generating from the POM, can the POM express "required-for-compilation-but-optional-for-users"? I didn't think it could...
          Hide
          Nathan Bubna added a comment -

          Only fixed in 1.7, for the time being.

          Show
          Nathan Bubna added a comment - Only fixed in 1.7, for the time being.
          Hide
          Sergiu Dumitriu added a comment -

          As for generating from the POM, can the POM express "required-for-compilation-but-optional-for-users"?

          The "provided" scope does something like that.

          Show
          Sergiu Dumitriu added a comment - As for generating from the POM, can the POM express "required-for-compilation-but-optional-for-users"? The "provided" scope does something like that.
          Hide
          Nathan Bubna added a comment -

          Fixed in 1.7.
          2.0 will probably use Maven to generate the manifest.

          Show
          Nathan Bubna added a comment - Fixed in 1.7. 2.0 will probably use Maven to generate the manifest.

            People

            • Assignee:
              Unassigned
              Reporter:
              Matt Ryall
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development