I am using a war type project, so the packaging is governed by maven-war-plugin. For the OSGi meta data in the war, I am using manifest goal of maven-bundle-plugin in process-classes phase. Yes, I have already looked at the excellent examples on this use case at [1]. However, my use case has one difference. I don't want "." in Bundle-ClassPath. Why? Because, it should never be. Files at the root level of .war file is never used directly by class loaders in web container; WEB-INF/classes and WEB-INF/lib/*.jar are used instead. As soon as I remove the "." from Bundle-ClassPath settings, bundle plugin is confused. I don't know why "." is necessary for bundle plugin to generate meta data? My guess is without it, it does not find any classes in the target dir? So, as a work around, I am having to specify Bundle-ClassPath using maven-war-plugin. Here is how plugin section of my pom.xml finally looks like:

       <plugins>
           <plugin>
               <artifactId>maven-war-plugin</artifactId>
               <groupId>org.apache.maven.plugins</groupId>
               <version>2.0</version>
               <configuration>
                   <archive>
                       <!-- add the generated manifest to the war -->
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> <!-- For some reason, adding Bundle-ClassPath in maven-bundle-plugin without "." confuses that plugin and it generates wrong Import-Package, etc.
                       Need to investigate further.
                       -->
                       <manifestEntries>
<Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
                       </manifestEntries>
                   </archive>
               </configuration>
           </plugin>
           <plugin>
               <groupId>org.apache.felix</groupId>
               <artifactId>maven-bundle-plugin</artifactId>
               <version>2.0.0</version>
               <configuration>
                   <supportedProjectTypes>
                       <supportedProjectType>jar</supportedProjectType>
                       <supportedProjectType>bundle</supportedProjectType>
                       <supportedProjectType>war</supportedProjectType>
                   </supportedProjectTypes>
                   <instructions>
<Bundle-Activator>sahoo.hybridapp.example1.impl.Activator</Bundle-Activator> <Export-Package>sahoo.hybridapp.example1</Export-Package>
                       <Web-ContextPath>/hybrid1</Web-ContextPath>
<!-- Specifying Bundle-ClassPath without "." confuses bundle plugin, as there are no classes in target/WEB-INF/classes/ and hence it can't do any processing. So, leave it unspecified and generate it
                              during war packaging.
<Bundle-ClassPath>WEB-INF/classes/</Bundle-ClassPath>
                       -->
                   </instructions>
               </configuration>
               <executions>
                   <execution>
                       <id>bundle-manifest</id>
                       <phase>process-classes</phase>
                       <goals>
                           <goal>manifest</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
       </plugins>

Is there any better way to handle this? Right now it is OK as I have only WEB-INF/classes as classpath entry, but when I have jars in WEB-INF/lib, it becomes a maintenance issue.

Thanks,
Sahoo

[1] http://wiki.ops4j.org/display/ops4j/Getting+the+benefits+of+maven-bundle-plugin+in+other+project+types

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

Reply via email to