2008/7/9 Danny Lin <[EMAIL PROTECTED]>: > 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

