Dear Wiki user, You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.
The following page has been changed by NiallPemberton: http://wiki.apache.org/commons/CommonsOsgi The comment on the change is: Update Component configuration for commons-parent-9 ------------------------------------------------------------------------------ === Commons OSGi === - The [http://felix.apache.org/ Apache Felix] project have [http://commons.markmail.org/message/36xoo2bo5aabvy5c requested] that Commons components include [http://www.osgi.org/ OSGi] meta data in their jars so that they are 'ready-to-use' in an OSGi environment. This involves OSGi entries in the jar's manifest file. + The purpose of this page is to record progress in Commons of ''OSGi-enabled'' releases and any notes on specific issues with configuration of the OSGi manifest entries. - The Felix project has developed a [http://felix.apache.org/site/maven-bundle-plugin-bnd.html Maven Plugin] which makes this easier (''version 1.2.0 released Jan '08''). Before that was released a number of components (Pool 1.4, !FileUpload 1.2.1 and IO 1.4) were manually configured with OSGi manifest entries. + The [http://felix.apache.org/ Apache Felix] project (an OSGi implementation) have [http://commons.markmail.org/message/36xoo2bo5aabvy5c requested] that Commons components include [http://www.osgi.org/ OSGi] meta data in their jars so that they are ''ready-to-use'' in an OSGi environment. This involves OSGi entries in the jar's manifest file. - The purpose of this page is to record progress in Commons of ''OSGi-enabled'' releases and any notes on specific issues with configuration of the OSGi manifest entries. + The Felix project has developed the [http://felix.apache.org/site/maven-bundle-plugin-bnd.html maven-bundle-plugin] which makes this easier and this is now configured + in the {{{commons-parent}}} [http://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk/pom.xml pom.xml] (since version 9) with ''default'' instructions. For components which need to override the ''default'' instructions, this can be done using ''properties'' in the component pom (see below for more details). == Proper == @@ -56, +57 @@ Having said that the Felix project has a bundle to re-package logging - see [http://svn.apache.org/repos/asf/felix/trunk/commons/commons-logging/pom.xml here] + == Configuring Commons Components for OSGi with Maven1 == + This can be done by specifying appropriate manifest entries for the jar plugin + (Pool 1.4 is an [http://svn.apache.org/repos/asf/commons/proper/pool/tags/POOL_1_4/project.properties example]) - however it is much easier using maven2 and the {{{maven-bundle-plugin}}}. - == Configuring OSGi with Maven2 == - There are two ways to do this: - * ''Bundle Plugin'' - using the Apache Felix project's [http://felix.apache.org/site/maven-bundle-plugin-bnd.html bundle Plugin] - * ''Manually'' - configuring the {{{maven-jar-plugin}}} with OSGi manifest entries + == Configuring Commons Components for OSGi with Maven2 == - '''N.B''' version 8 of the commons-parent pom includes configuration for the felix bundle plugin which should be sufficient for most components. To use that a component needs to do the following: - * use version 9 of commons-parent - * specify {{{<packaging>bundle</packaging>}}} - * add a ''property'' with the component's name in lower case - === Felix's Maven2 Bundle Plugin === - To configure the plugin, specify a {{{ <packaging>bundle</packaging> }}} element in the pom - and configure the plugin in the {{{ <build> }}} section, for example for Commons Lang + The latest version of the [http://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk/pom.xml commons-parent pom] confugures the + [http://felix.apache.org/site/maven-bundle-plugin-bnd.html maven-bundle-plugin]'s ''instructions'' using ''properties'' in the following way: + {{{ - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>1.2.0</version> - <extensions>true</extensions> - <configuration> - <excludeDependencies>true</excludeDependencies> - <instructions> + <instructions> + <!-- stops the "uses" clauses being added to "Export-Package" manifest entry --> + <_nouses>true</_nouses> - <Bundle-SymbolicName>org.apache.commons.lang</Bundle-SymbolicName> + <Bundle-SymbolicName>${commons.osgi.symbolicName}</Bundle-SymbolicName> - <Export-Package>*;version=${pom.version}</Export-Package> + <Export-Package>${commons.osgi.export}</Export-Package> + <Private-Package>${commons.osgi.private}</Private-Package> + <Import-Package>${commons.osgi.import}</Import-Package> + <DynamicImport-Package>${commons.osgi.dynamicImport}</DynamicImport-Package> + <Bundle-DocURL>${project.url}</Bundle-DocURL> - </instructions> + </instructions> - </configuration> - </plugin> }}} - '''Notes:''' - * {{{<extensions>true</extensions>}}} needs to be specified otherwise the {{{ <packaging>bundle</packaging> }}} is not recognized and causes an error with the message ''Cannot find lifecycle mapping for packaging '''bundle''''' - * {{{<excludeDependencies>true</excludeDependencies>}}} prevents all the component's dependencies classes being included in the jar - * Other '''''Manifest''''' entries are inherited from the commons-parent pom - * Depending on the nature/structure of the project, some packages might contain private classes that are not meant to be used by client code. In these cases, {{{<Export-Package>}}} should list all public packages while {{{<Private-Package>}}} should contain the private packages. - === Configuring via the jar plugin === + This allows component poms to easily override the ''default'' values, by specifying alternative values for these properties in their pom. The default values for these properties in commons-parent are: + {{{ + <properties> + <commons.osgi.symbolicName>org.apache.commons.${commons.componentid}</commons.osgi.symbolicName> + <commons.osgi.export>org.apache.commons.*;version=${pom.version}</commons.osgi.export> + <commons.osgi.import>*</commons.osgi.import> + <commons.osgi.dynamicImport></commons.osgi.dynamicImport> + <commons.osgi.private></commons.osgi.private> + </properties> + }}} - {{{ - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifestEntries> - <Bundle-SymbolicName>org.apache.commons.lang</Bundle-SymbolicName> - <Bundle-License>http://www.apache.org/licenses/LICENSE-2.0.txt</Bundle-License> - <Bundle-ManifestVersion>2</Bundle-ManifestVersion> - <Bundle-Name>Apache Commons Lang Bundle</Bundle-Name> - <Bundle-Vendor>${project.organization.name}</Bundle-Vendor> - <Bundle-Version>${project.version}</Bundle-Version> - <Export-Package> - org.apache.commons.lang;version=${project.version}, - org.apache.commons.lang.builder;version=${project.version}, - org.apache.commons.lang.enum;version=${project.version}, - org.apache.commons.lang.enums;version=${project.version}, - org.apache.commons.lang.exception;version=${project.version}, - org.apache.commons.lang.math;version=${project.version}, - org.apache.commons.lang.mutable;version=${project.version}, - org.apache.commons.lang.text;version=${project.version}, - org.apache.commons.lang.time;version=${project.version} - </Export-Package> - <Import-Package> - org.apache.commons.lang;version=${project.version}, - org.apache.commons.lang.builder;version=${project.version}, - org.apache.commons.lang.enum;version=${project.version}, - org.apache.commons.lang.enums;version=${project.version}, - org.apache.commons.lang.exception;version=${project.version}, - org.apache.commons.lang.math;version=${project.version}, - org.apache.commons.lang.mutable;version=${project.version}, - org.apache.commons.lang.text;version=${project.version}, - org.apache.commons.lang.time;version=${project.version} - </Import-Package> - </manifestEntries> - </archive> - </configuration> - </plugin> - }}} - '''Notes:''' - * As you can see by the example, you should always import everything you export. - * The note about private packages from above applies here of course as well. + For example, depending on the nature/structure of the project, some packages might contain private classes that are not meant to be used by client code. In these cases, <Export-Package> should list all public packages while <Private-Package> should contain the private packages. This can be achieved by overriding the {{{<commons.osgi.export>}}} and {{{<commons.osgi.private>}}} properties in the component pom. + + Version 8 of commons-parent required specifing {{{<packaging>bundle</packaging>}}} in the component pom - with version 9 this is no longer required. In version 9, + the {{{maven-bundle-plugin}}} is configured to generate a {{{MANIFEST.MF}}} file containing the OSGi ''meta data'' in the {{{target/osgi}}} folder. The {{{maven-jar-plugin}}} is configured to merge this generated {{{MANIFEST.MF}}} file with the manifest entries it is configured with. If a component does not want to include OSGi meta-data in their pom's manifest file they can configure an alternative or blank manifest file location using the {{{<commons.manifestfile>}}} property. + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]