Lets collect tips on osgi conversion here
jars with xmlbeans compilation
To use xmlbeans generated code you need access to the SchemaTypeSystemImpl, which is not imported by the maven-bundle-plugin. So you need to add something like this to the pom:
<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <!--packages containing "impl" or "internal" are excluded by default --> <Import-Package>org.apache.xmlbeans.impl.schema;version="2.4",*</Import-Package> <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>--> </instructions> </configuration> </plugin>
Also, any package we may have with "impl" or "internal" needs to be explicitly listed in the Export-Packages.
Non-bundle interference
Many problems with building plugins are caused by non-bundle dependencies getting installed in felix rather than bundleized equivalents. Unfortuneately it looks like felix only says "non-framework bundles cannot be started" without telling us the location of the non-bundle. Running
mvn dependency:tree
helps to find the bad dependencies. On a related note, generally you have to exclude original jars from the dependencyManagement dependency entry of a bundleized repackaging. This seems like a serious defect in maven-bundle-plugin.
Assemble a server to make sure each set of plugins starts.
I think it's a good idea to assemble a server for each set of plugins to make sure they at least start. Here's how:
- run
where <foo> is your set of plugins
mvn archetype:create \ -DarchetypeGroupId=org.apache.geronimo.buildsupport \ -DarchetypeArtifactId=geronimo-assembly-archetype \ -DarchetypeVersion=3.0-SNAPSHOT \ -DgroupId=org.apache.geronimo.plugins \ -DartifactId=geronimo-<foo>-server
- add it to svn
- add the plugins you want to test as depedendencies
- add this to start the server when run with -Pit
in plugin management:and a profile<plugin> <groupId>org.apache.geronimo.buildsupport</groupId> <artifactId>geronimo-maven-plugin</artifactId> <version>${version}</version> <configuration> <assemblyArchive>${project.build.directory}/${pom.artifactId}-${pom.version}-bin.zip</assemblyArchive> <optionSets> <optionSet> <id>morememory</id> <options> <option>-Xmx512m</option> <option>-XX:MaxPermSize=128m</option> </options> </optionSet> <optionSet> <id>debug</id> <options> <option>-Xdebug</option> <option>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</option> </options> </optionSet> </optionSets> </configuration> <executions> <execution> <id>start</id> <phase>pre-integration-test</phase> <goals> <goal>start-server</goal> </goals> <configuration> <assemblyId>${it-server}</assemblyId> <logOutput>true</logOutput> <background>true</background> <verifyTimeout>300</verifyTimeout> <refresh>true</refresh> <optionSets> <optionSet> <id>default</id> <options> <option>-XX:MaxPermSize=128m</option> </options> </optionSet> <optionSet> <id>morememory</id> <options> <option>-Xmx512m</option> <option>-XX:MaxPermSize=128m</option> </options> </optionSet> <optionSet> <id>debug</id> <options> <option>-Xdebug</option> <option>-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n</option> </options> </optionSet> </optionSets> </configuration> </execution> <execution> <id>stop</id> <phase>install</phase> <goals> <goal>stop-server</goal> </goals> </execution> </executions> </plugin>
<profiles> <profile> <id>it</id> <build> <plugins> <plugin> <groupId>org.apache.geronimo.buildsupport</groupId> <artifactId>geronimo-maven-plugin</artifactId> </plugin> </plugins> </build> </profile> </profiles>
Note that at the moment the -Pit doesn't actually work, you have to try to start the server by hand
Logging conversion
When converting plugins make sure to avoid the following dependencies: log4j
, jcl-over-slf4j
,
jul-to-slf4j
, slf4j-api
, or slf4j-log4j12
. Instead use pax-logging-api
. This bundle exports all of these logging API.
<dependency> <groupId>org.ops4j.pax.logging</groupId> <artifactId>pax-logging-api</artifactId> </dependency>
The pax-logging-api
together with pax-logging-service
provides a logging service in the OSGi environment that works with all commonly used logging API.