2009/6/13 Sahoo <sa...@sun.com>

> 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?


if you want to use the bundleplugin to build the WAR file then you need
to use Embed-Dependency (or the raw Bnd Include-Resouce instruction)
so that the classes end up in the right location(s) inside the WAR bundle
- then when Bnd analyzes the Bundle-ClassPath it will find the classes

if you want to use the bundleplugin to generate the manifest, and you
want a Bundle-ClassPath without '.' then I suspect you'll need to have
the WAR file laid out under "target/classes" (or somewhere else that
you could add to the Bnd classpath by using its -classpath setting)

otherwise I suspect the reason you're getting unexpected results is
because Bnd is looking for the given structure, but the classpath it's
been given is just the basic compilation path.

also the key difference between the bundle and manifest goals is that
the manifest goal doesn't actually generate the bundle, so there may
still be some inconsistencies due to this (and some may be impossible
to solve without actually generating the bundle - in which case you'd
might as well use the bundle goal and then extract the manifest...)

feel free to attach your testcase to a JIRA issue (make sure it can be
built without missing dependencies, etc.) ... unfortunately I can't say
for sure when I'll be able to get round to actively look at it

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
>
>


-- 
Cheers, Stuart

Reply via email to