You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Danny Lin <da...@trionworld.com> on 2008/07/09 01:29:35 UTC

Existing Jar --> Bundle Conversion

Hello,

I am trying to convert the Jasypt 1.4.1 library to an osgi compliant bundle; however, I am getting errors when I try to export the packages in the libraries. Am I doing something wrong in my pom.xml? I keep getting the following error:

[WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Instructions for Export-Package that are never used: org\.jasypt.*
[WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Superfluous export-package instructions: [org.jasypt*]
[WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Did not find matching referal for *

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
            <modelVersion>4.0.0</modelVersion>

            <groupId>foo.bar.org.jasypt</groupId>
            <artifactId>jasypt</artifactId>
            <version>1.4.1</version>
            <packaging>bundle</packaging>
            <name>${pom.artifactId}</name>

            <build>
                        <plugins>
                                    <plugin>
                                                <groupId>org.apache.felix</groupId>
                                                <artifactId>maven-bundle-plugin</artifactId>
                                                <version>1.2.1</version>
                                                <extensions>true</extensions>
                                                <configuration>
                                                            <manifestLocation>
                                                                        src/main/resources/META-INF
                                                            </manifestLocation>
                                                            <instructions>
                                                                        <Export-Package>
                                                                                    org.jasypt*
                                                                        </Export-Package>
                                                                        <Embed-Dependency>
                                                                                    *;scope=compile|runtime;inline=false
                                                                        </Embed-Dependency>
                                                            </instructions>
                                                </configuration>
                                                <executions>
                                                            <execution>
                                                                        <id>manifest</id>
                                                                        <goals>
                                                                                    <goal>manifest</goal>
                                                                        </goals>
                                                                        <phase>process-resources</phase>
                                                            </execution>
                                                </executions>
                                    </plugin>
                        </plugins>
            </build>

            <scm>
                        <connection>${p4.cerberus}/MAIN/${project.artifactId}</connection>
                        <developerConnection>${scm.connection}</developerConnection>
                        <tag>HEAD</tag>
            </scm>

            <dependencies>

                        <dependency>
                                    <groupId>org.jasypt</groupId>
                                    <artifactId>jasypt</artifactId>
                                    <version>1.4.1</version>
                        </dependency>

            </dependencies>
</project>






Danny Hao-Yei Lin
Software Engineer
Trion World Network, Inc.


Re: Existing Jar --> Bundle Conversion

Posted by Sahoo <Sa...@Sun.COM>.
I am confused with your pom.xml:
1. Why do you have to execute manifest goal of maven-bundle-plugin when 
your packaging type is bundle?

2. Even if you want to run manifest goal, why do you tie it to 
process-resources phase? Should it not be run after source is compiled, 
which means in process-classes phase?

3.  What are the packages inside the original jar? Do they all start 
with pattern "org.jasypt*" ? If yes, then try doing just this:

                                                <groupId>org.apache.felix</groupId>
                                                <artifactId>maven-bundle-plugin</artifactId>
                                                <version>1.4.1</version>
                                                <extensions>true</extensions>
                                                <configuration>
                                                            <instructions>
                                                                        <Export-Package>
                                                                                    org.jasypt*
                                                                        </Export-Package>
                                                                        <Embed-Dependency>
                                                                                    *;scope=compile|runtime;inline=true
                                                                        </Embed-Dependency>
                                                            </instructions>
                                                </configuration>

Thanks,
Sahoo

Danny Lin wrote:
> Hello,
>
> I am trying to convert the Jasypt 1.4.1 library to an osgi compliant bundle; however, I am getting errors when I try to export the packages in the libraries. Am I doing something wrong in my pom.xml? I keep getting the following error:
>
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Instructions for Export-Package that are never used: org\.jasypt.*
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Superfluous export-package instructions: [org.jasypt*]
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 : Did not find matching referal for *
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>             <modelVersion>4.0.0</modelVersion>
>
>             <groupId>foo.bar.org.jasypt</groupId>
>             <artifactId>jasypt</artifactId>
>             <version>1.4.1</version>
>             <packaging>bundle</packaging>
>             <name>${pom.artifactId}</name>
>
>             <build>
>                         <plugins>
>                                     <plugin>
>                                                 <groupId>org.apache.felix</groupId>
>                                                 <artifactId>maven-bundle-plugin</artifactId>
>                                                 <version>1.2.1</version>
>                                                 <extensions>true</extensions>
>                                                 <configuration>
>                                                             <manifestLocation>
>                                                                         src/main/resources/META-INF
>                                                             </manifestLocation>
>                                                             <instructions>
>                                                                         <Export-Package>
>                                                                                     org.jasypt*
>                                                                         </Export-Package>
>                                                                         <Embed-Dependency>
>                                                                                     *;scope=compile|runtime;inline=false
>                                                                         </Embed-Dependency>
>                                                             </instructions>
>                                                 </configuration>
>                                                 <executions>
>                                                             <execution>
>                                                                         <id>manifest</id>
>                                                                         <goals>
>                                                                                     <goal>manifest</goal>
>                                                                         </goals>
>                                                                         <phase>process-resources</phase>
>                                                             </execution>
>                                                 </executions>
>                                     </plugin>
>                         </plugins>
>             </build>
>
>             <scm>
>                         <connection>${p4.cerberus}/MAIN/${project.artifactId}</connection>
>                         <developerConnection>${scm.connection}</developerConnection>
>                         <tag>HEAD</tag>
>             </scm>
>
>             <dependencies>
>
>                         <dependency>
>                                     <groupId>org.jasypt</groupId>
>                                     <artifactId>jasypt</artifactId>
>                                     <version>1.4.1</version>
>                         </dependency>
>
>             </dependencies>
> </project>
>
>
>
>
>
>
> Danny Hao-Yei Lin
> Software Engineer
> Trion World Network, Inc.
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


RE: Existing Jar --> Bundle Conversion

Posted by Danny Lin <da...@trionworld.com>.
Thanks you guys!! That was a very thorough explanation and examination of my pom.xml. I learned a lot about creating bundles.

As it turns out, I had an additional issue with my jasypt jar being corrupt. It was causing the superfluous * warnings, since it couldn't find the necessary classes. Deleting my local maven repository fixed that issue.

Thanks,
Danny


-----Original Message-----
From: mcculls@gmail.com [mailto:mcculls@gmail.com] On Behalf Of Stuart McCulloch
Sent: Tuesday, July 08, 2008 10:36 PM
To: users@felix.apache.org
Subject: Re: Existing Jar --> Bundle Conversion

Also, when you start to wrap third-party libraries as bundles it is a good
idea to use:

  <Import-Package>*;resolution:=optional</Import-Package>

to mark all the imports as optional - that means you won't have to go and
bundle all
the dependencies used by the library (which might include tool interfaces
like Ant),
just the ones that you actually use at runtime...

--
Cheers, Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Existing Jar --> Bundle Conversion

Posted by Stuart McCulloch <st...@jayway.net>.
Also, when you start to wrap third-party libraries as bundles it is a good
idea to use:

  <Import-Package>*;resolution:=optional</Import-Package>

to mark all the imports as optional - that means you won't have to go and
bundle all
the dependencies used by the library (which might include tool interfaces
like Ant),
just the ones that you actually use at runtime...

-- 
Cheers, Stuart

Re: Existing Jar --> Bundle Conversion

Posted by Stuart McCulloch <st...@jayway.net>.
2008/7/9 Danny Lin <da...@trionworld.com>:

> Hello,
>
> I am trying to convert the Jasypt 1.4.1 library to an osgi compliant
> bundle; however, I am getting errors when I try to export the packages in
> the libraries. Am I doing something wrong in my pom.xml? I keep getting the
> following error:
>
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 :
> Instructions for Export-Package that are never used: org\.jasypt.*
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 :
> Superfluous export-package instructions: [org.jasypt*]
> [WARNING] Warning building bundle foo.bar.org.jasypt:jasypt:bundle:1.4.1 :
> Did not find matching referal for *
>

Hi Danny,

I wasn't able to recreate these particular warnings with the pom below,
but as Sahoo said, there are a few things with it that don't look right...


> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
> ">
>            <modelVersion>4.0.0</modelVersion>
>
>            <groupId>foo.bar.org.jasypt</groupId>
>            <artifactId>jasypt</artifactId>
>            <version>1.4.1</version>
>            <packaging>bundle</packaging>
>            <name>${pom.artifactId}</name>
>

ok - I'm going to assume you want to build a new jar with OSGi metadata
based on an existing artifact - if you wanted to OSGi-fy an existing build
pom then you'd use a slightly different technique, depending on whether
you wanted the bundleplugin to create the final jar or just the manifest...

           <build>
>                        <plugins>
>                                    <plugin>
>
>  <groupId>org.apache.felix</groupId>
>
>  <artifactId>maven-bundle-plugin</artifactId>
>                                                <version>1.2.1</version>


FYI, the latest release is 1.4.1 - I'd strongly suggest upgrading to this
level


>
> <extensions>true</extensions>
>                                                <configuration>
>
>  <manifestLocation>
>
>  src/main/resources/META-INF
>
>  </manifestLocation>


the manifestLocation is where the bundleplugin will write the generated
manifest - you typically don't want this written to somewhere like "src"
unless you want to capture the generated output in your SCM system,
so you can safely remove this (it won't affect the final jar)

because you're using <packaging>bundle</packaging> then the final
jar will be created by the bundleplugin, which will include the correct
manifest - it's only if you're using another <packaging> that you need
to worry about including the generated manifest in the final jar.

                                                           <instructions>
>
>  <Export-Package>
>
>        org.jasypt*
>
>  </Export-Package>


here you are telling Bnd to add all the packages starting with org.jasypt
to the final bundle, and mark them as exported. Note that if the original
artifact contained other packages or resources that didn't start with this
prefix then they wouldn't be added.


>
> <Embed-Dependency>
>
>        *;scope=compile|runtime;inline=false
>
>  </Embed-Dependency>


here you're asking for the direct dependencies to be added to the bundle
as embedded jars. This means the bundle will contain both the org.jasypt
packages (included from the first export instruction) and an embedded jar
(included from the embed instruction) which I don't think you want.

if you want the jasypt contents inlined inside your bundle then use:

  <Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
  <Export-Package>org.jasypt*</Export-Package>

or more simply:

  <Export-Package>org.jasypt*</Export-Package>

if you know that the contents of the jasypt jar all start with this prefix.

however, if for some reason you wanted the jasypt jar embedded inside
the bundle rather than inlined then you'd use the following instructions:

  <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
  <_exportcontents>org.jasypt*</_exportcontents>
  <Private-Package>!*</Private-Package>

the <_exportcontents> acts just like <Export-Package> except that it
won't *pull* the packages into the final jar, just mark them as exported.
(the Private-Package is there to workaround a bogus warning in 1.4.1)

                                                           </instructions>
>                                                </configuration>
>                                                <executions>
>                                                            <execution>
>
>  <id>manifest</id>
>
>  <goals>
>
>        <goal>manifest</goal>
>
>  </goals>


as Sahoo says, you don't need to use the manifest goal because you
have <packaging>bundle</packaging> so the final jar will already have
the correct manifest, as part of the bundle life-cycle


>
> <phase>process-resources</phase>
>                                                            </execution>
>                                                </executions>
>                                    </plugin>
>                        </plugins>
>            </build>
>
>            <scm>
>
>  <connection>${p4.cerberus}/MAIN/${project.artifactId}</connection>
>
>  <developerConnection>${scm.connection}</developerConnection>
>                        <tag>HEAD</tag>
>            </scm>
>
>            <dependencies>
>
>                        <dependency>
>                                    <groupId>org.jasypt</groupId>
>                                    <artifactId>jasypt</artifactId>
>                                    <version>1.4.1</version>
>                        </dependency>
>
>            </dependencies>
> </project>
>
> Danny Hao-Yei Lin
> Software Engineer
> Trion World Network, Inc.
>

complete details on how to configure the bundleplugin can be found here:

   http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

HTH

-- 
Cheers, Stuart