Adding Non-Plugin Modules to Commerce Manager
If you have created a new Commerce Engine Extension jar module (e.g.
ext-settings), or you have introduced a new third-party dependency (e.g.
org.apache.commons:commons-text), you will likely need to add this module to the Commerce Manager, particularly if the module is a dependency of
New non-plugin modules can be made available to the Commerce Manager by embedding them within the
ext-cm-libs is a project which bundles together all extension libraries that must be deployed within Commerce Manager via an OSGi manifest. It also acts as a wrapper for libraries that are non-OSGi bundles, making their contents available to the OSGi container.
Adding modules to
To add modules to
com.elasticpath.extensions.cm.ext-cm-libs, modify the
commerce-extensions/cm/ext-cm-libs/pom.xml file and add your module to the
<dependencies> <!-- existing dependencies --> <dependency> <groupId>the.group.id</groupId> <artifactId>your-artifact-id-here</artifactId> </dependency> </dependencies>
To ensure that the module is included within the
com.elasticpath.extensions.cm.ext-cm-libs bundle, add its artifact ID to the
EmbedDependency entry within the
Exposing non-OSGi Classes to OSGi Bundles
If your module is a non-OSGi module, it’s like that it provides classes that need to be accessed by other bundles, perhaps to assign or instantiate a variable, in an
instanceof condition, or in a
catch block. In this case it must be exported from the
OSGi bundles only provide access to packages that are explicitly exported - if a class in a non-exported package is attempted to be loaded by another bundle, it will cause a
A key role of the
com.elasticpath.extensions.cm.ext-cm-libs project is to allow non-OSGi modules to participate in an OSGi container. Part of its responsibility is to export the required packages on the embedded modules’ behalf.
Add the required packages to the
maven-bundle-plugin configuration within
<_exportcontents> org.some.package.to.export, org.some.other.package.to.export, com.elasticpath.extensions.* </_exportcontents>
The nature of OSGi applications tends to make the previous step iterative; exporting one package reveals another that is also required. Add your dependency, as well as any other dependancies required.