-
1. Re: Converting WAR to OSGi world: what to do with embedded dependencies
thomas.diesler Dec 21, 2012 4:47 AM (in response to jrantav)Embed-* is not a standard OSGi header. This seems to be a tools issue - maybe you need to ask there.
-
2. Re: Converting WAR to OSGi world: what to do with embedded dependencies
jrantav Dec 21, 2012 4:56 AM (in response to thomas.diesler)1 of 1 people found this helpfulAh. Correct. From http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
The plugin uses the <Embed-Dependency> instruction to transform the project dependencies into <Include-Resource> and <Bundle-ClassPath> clauses, which are then appended to the current set of instructions and passed onto BND. If you want the embedded dependencies to be at the start or middle of <Include-Resource> or <Bundle-ClassPath> then you can use {maven-dependencies}, which will automatically expand to the relevant clauses.
Thanks.
-
3. Re: Converting WAR to OSGi world: what to do with embedded dependencies
jrantav Dec 21, 2012 5:23 AM (in response to jrantav)1 of 1 people found this helpfulFor the interested...
To take advantage of those directives, on maven pom, one would transform this kind of pom directive:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <manifestEntries> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-ClassPath> ., WEB-INF/classes, WEB-INF/lib/slf4j-api-1.6.6.jar, WEB-INF/lib/aopalliance-1.0.jar, WEB-INF/lib/aspectjrt-1.6.10.jar, WEB-INF/lib/spring-aop-3.1.3.RELEASE.jar, WEB-INF/lib/spring-asm-3.1.3.RELEASE.jar, WEB-INF/lib/spring-beans-3.1.3.RELEASE.jar, WEB-INF/lib/spring-context-3.1.3.RELEASE.jar, WEB-INF/lib/spring-context-support-3.1.3.RELEASE.jar, WEB-INF/lib/spring-core-3.1.3.RELEASE.jar, WEB-INF/lib/spring-expression-3.1.3.RELEASE.jar, WEB-INF/lib/spring-web-3.1.3.RELEASE.jar, WEB-INF/lib/spring-webmvc-3.1.3.RELEASE.jar, WEB-INF/lib/org.eclipse.gemini.blueprint.core-1.0.2.RELEASE.jar, WEB-INF/lib/org.eclipse.gemini.blueprint.extender-1.0.2.RELEASE.jar, WEB-INF/lib/org.eclipse.gemini.blueprint.io-1.0.2.RELEASE.jar </Bundle-ClassPath> <Bundle-ManifestVersion>2</Bundle-ManifestVersion> <Bundle-Version>1.0.0.SNAPSHOT</Bundle-Version> <Import-Package> javax.annotation, javax.servlet;version="[2.5,3.0]", javax.servlet.http;version="[2.5,3.0]", org.osgi.service.http, org.osgi.service.packageadmin, org.osgi.framework;version="[1.5,2.0)", org.jboss.logging;version="[3.0,4.0)", fi.eis.applications.jboss.poc.osgiservice.api;version="[0.0,1.0)", fi.eis.applications.jboss.poc.compositeservice.gemini.api </Import-Package> <Private-Package>fi.eis.applications</Private-Package> <Web-ContextPath>/spring-app</Web-ContextPath> </manifestEntries> </archive> </configuration> </plugin>
into this:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <!-- add the generated manifest to the war --> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </archive> <failOnMissingWebXml>true</failOnMissingWebXml> <packagingExcludes>WEB-INF/web.xml</packagingExcludes> </configuration> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <executions> <execution> <id>bundle-manifest</id> <phase>process-classes</phase> <goals> <goal>manifest</goal> </goals> </execution> </executions> <configuration> <supportedProjectTypes> <supportedProjectType>jar</supportedProjectType> <supportedProjectType>bundle</supportedProjectType> <supportedProjectType>war</supportedProjectType> </supportedProjectTypes> <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-ClassPath>.,WEB-INF/classes,{maven-dependencies}</Bundle-ClassPath> <Bundle-ManifestVersion>2</Bundle-ManifestVersion> <Embed-Directory>WEB-INF/lib</Embed-Directory> <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> <Embed-Transitive>true</Embed-Transitive> <Import-Package> javax.annotation, javax.servlet;version="[2.5,3.0]", javax.servlet.http;version="[2.5,3.0]", org.osgi.service.http, org.osgi.service.packageadmin, org.osgi.framework;version="[1.5,2.0)", org.jboss.logging;version="[3.0,4.0)", fi.eis.applications.jboss.poc.osgiservice.api;version="[0.0,1.0)", fi.eis.applications.jboss.poc.compositeservice.gemini.api </Import-Package> <Private-Package>fi.eis.applications</Private-Package> <Web-ContextPath>/spring-app</Web-ContextPath> </instructions> </configuration> </plugin>
and then maven-bundle-plugin will generate equal manifest, and the app works without issues. Highly valuable knowledge.