dev@glassfish.java.net

Re: pom.xml help?

From: Sahoo <Sahoo_at_Sun.COM>
Date: Sat, 12 Jul 2008 10:47:06 +0530

By the way, since you are wrapping a library, you don't have to list
package names in Export-Package. You can use _exportcontents as shown below:
           <plugin>
               <groupId>org.apache.felix</groupId>
               <artifactId>maven-bundle-plugin</artifactId>
               <configuration>
                   <instructions>
                       
<Embed-Dependency>artifactId=dataprovider;inline=true;</Embed-Dependency>
                       *<_exportcontents>*</_exportcontents>*
                       <Import-Package>com.sun.sql.rowset;
resolution=optional, *</Import-Package>
                   </instructions>
               </configuration>
               ...

Having said that, there is no harm done if we use Export-Package. The
difference between Export-Package and _exportcontents is that
Export-Package can pull more or less classes into the jar in addition to
affecting the manifest, where as _exportcontents only affects manifest
calculation. So, Export-Package can also pull classes from dependencies.

Thanks,
Sahoo

Sahoo wrote:
> You can mark that to be optional like this:
>
> <instructions>
> <Import-Package>com.sun.sql.rowset; resolution=optional,
> *</Import-Package>
> </instructions>
>
> Thanks,
> Sahoo
>
> Ken Paulsen wrote:
>>
>> I am trying to repackage an external jar file (dataprovider.jar) to
>> be an OSGi bundle. This jar file has a class in it which depends on
>> "com.sun.sql.rowset". If you don't use that part of the
>> functionality (we don't), everything works just fine... so we haven't
>> included "dataprovider-rowset.jar" in GlassFish before. Question:
>>
>> How do I make this dependency not required?
>>
>> When I attempt to deploy my app app which depends on the re-packaged
>> dataprovider.jar I get this error:
>> at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
>>
>> at
>> com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:169)
>> Caused by: org.osgi.framework.BundleException: Unresolved package in
>> bundle 24: package; (package=com.sun.sql.rowset)
>> at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1728)
>> at org.apache.felix.framework.Felix._startBundle(Felix.java:1591)
>> at org.apache.felix.framework.Felix.startBundle(Felix.java:1544)
>> at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:371)
>> at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl.resolve(OSGiModuleImpl.java:109)
>>
>>
>> The pom.xml file does this:
>>
>> ...
>> <packaging>jar</packaging>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.felix</groupId>
>> <artifactId>maven-bundle-plugin</artifactId>
>> <configuration>
>> <instructions>
>>
>> <Embed-Dependency>artifactId=dataprovider;inline=true;</Embed-Dependency>
>>
>> <Export-Package>com.sun.data.*;</Export-Package>
>> </instructions>
>> </configuration>
>> <executions>
>> <execution>
>> <id>osgi-bundle</id>
>> <phase>package</phase>
>> <goals>
>> <goal>bundle</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>> <dependencies>
>> <dependency>
>> <groupId>com.sun.woodstock</groupId>
>> <artifactId>dataprovider</artifactId>
>> <version>1.4.2-SNAPSHOT</version>
>> </dependency>
>> </dependencies>
>>
>> My MANIFEST.MF file for the repackaged dataprovider.jar is:
>>
>> Manifest-Version: 1.0
>> Export-Package: com.sun.data.provider.impl;uses:="com.sun.sql.rowset,c
>> om.sun.data.provider,javax.sql.rowset.serial,javax.sql,javax.sql.rows
>> et.spi,javax.sql.rowset",com.sun.data.provider
>> Built-By: paulsen
>> Tool: Bnd-0.0.255
>> Bundle-Name: DataProvider
>> Created-By: Apache Maven Bundle Plugin
>> Bundle-Vendor: Sun Microsystems, Inc.
>> Build-Jdk: 1.6.0_06
>> Bundle-Version: 1.4.2.SNAPSHOT
>> Bnd-LastModified: 1215830659602
>> Bundle-ManifestVersion: 2
>> Bundle-License: https://glassfish.dev.java.net/nonav/public/CDDL+GPL.h
>> tml
>> Bundle-Description: DataProvider Repackaged as OSGi bundle for GlassFi
>> sh
>> Embed-Dependency: artifactId=dataprovider;inline=true;
>> Bundle-DocURL: http://www.sun.com
>> Bundle-SymbolicName: org.glassfish.admingui.dataprovider
>> Import-Package: com.sun.data.provider,com.sun.data.provider.impl,com.s
>> un.sql.rowset,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,java
>> x.sql.rowset.spi
>>
>> I'd be happy if I could exclude the class that refers to this file
>> from repackaged bundle
>> (com/sun/data/provider/impl/CachedRowSetDataProvider.class), however,
>> I haven't figured out how to do that. Or if I can make the
>> dataprovider-rowset.jar optional (currently it's not even stored in a
>> maven repository as we've never used it before). Or any other way to
>> do this that causes it to ignore this dependency that I don't want to
>> have. Ideas?
>>
>> Thanks,
>>
>> Ken
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>