1. Migrate from Oscar to Felix

Several tools [1] were created in the Felix [2] project to help developer to create bundles.

1.1. Requirements

  • Maven [3][4]

  • The Maven Eclipse plugin [5]

1.2. Maven-ize the bundle project

Maven use a specific directory scheme for its project, so it could be better to use it :

  • main/src/java for sources

  • main/src/resources for resources which will be included in your bundle

Create a file named pom.xml in the root directory of your project.

<?xml version="1.0" encoding="UTF-8"?>
<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>org.ow2.jasmine.jade.wrapper</groupId>
  <artifactId>org.ow2.jasmine.jade.wrapper.a_name_for_your_project</artifactId>
  <packaging>bundle</packaging>
  <name>The name of your project</name>
  <version>The version of your project</version>
  <description>A description of your bundle</description>

  <dependencies>
    <dependency>
      <groupId>org.ow2.jasmine.jade</groupId>
      <artifactId>jade</artifactId>
      <version>2.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.ow2.jasmine.jade</groupId>
      <artifactId>jade-fractal</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>
</project>

The best practice for dependencies management is to use Maven repositories instead of including libraires in the project and adding them in the classpath. This way can be used if librairies can't be found in repositories Maven. TODO add a configuration for Maven repositories to use (OW2, ...) cf settings.xml

1.3. Use the maven-bundle plugin

Add this template in your pom.xml

<project ...>

  ...

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>1.1.0-SNAPSHOT</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
            <_include>-target/classes/META-INF/${pom.artifactId}.bnd</_include>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

  ...

</project>
[Note]Note

The use of the * pattern tells BND plugin to import all packages described (import x.y.z;) in the Java file. We manually specify pacckages because they are not referenced in Java file but are needed by Jade.

Create a file in the directory src/main/resources/META-INF/org.ow2.jasmine.jade.wrapper.a_name_for_your_project.bnd (the name of the file is the ID of your artifact described in the pom.xml). specify packages to export, import, ... in bnd file (cf BND documentation http://felix.apache.org/site/maven-bundle-plugin-bnd.html)

Export-Package org.ow2.jasmine.jade.wrapper.xxx;version=2.2.2,\
 org.ow2.jasmine.jade.wrapper.xxx.configurator;version=2.2.2,\
 org.ow2.jasmine.jade.wrapper.xxx.launcher;version=2.2.2

Import-Package org.ow2.jasmine.jade.legacy.xxx,\
 org.ow2.jasmine.jade.fractal.adl.attributes;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.adl.components;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.api.control;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia.control.deployment;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia.control.genericattribute;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia.control.binding;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia.control.reversebinding;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.julia.control.factory;version=1.0.0,\
 org.ow2.jasmine.jade.fractal.util;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.api.control;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.api.factory;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control.binding;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control.attribute;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control.content;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control.lifecycle;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.control.name;version=1.0.0,\
 org.ow2.jasmine.jade.reflex.util;version=1.0.0,\
 org.objectweb.jasmine.jade.resource;version=2.0.0,\
 org.objectweb.jasmine.jade.resource.start;version=2.0.0,\
 org.objectweb.jasmine.jade.service;version=2.0.0,\
 org.objectweb.jasmine.jade.service.allocator;version=2.0.0,\
 org.objectweb.jasmine.jade.util;version=2.0.0,\
 org.objectweb.asm,org.objectweb.asm.signature,\
 org.objectweb.fractal.deployment.local.api,\
 org.objectweb.fractal.adl,\
 org.objectweb.fractal.adl.arguments,\
 org.objectweb.fractal.adl.attributes,\
 org.objectweb.fractal.adl.bindings,\
 org.objectweb.fractal.adl.comments,\
 org.objectweb.fractal.adl.components,\
 org.objectweb.fractal.adl.coordinates,\
 org.objectweb.fractal.adl.implementations,\
 org.objectweb.fractal.adl.interfaces,\
 org.objectweb.fractal.adl.loggers,\
 org.objectweb.fractal.adl.nodes,\
 org.objectweb.fractal.adl.types,\
 org.objectweb.fractal.adl.util,\
 org.objectweb.fractal.adl.xml,\
 org.objectweb.fractal.api,\
 org.objectweb.fractal.api.control,\
 org.objectweb.fractal.api.factory,\
 org.objectweb.fractal.api.type,\
 org.objectweb.fractal.util,\
 org.objectweb.fractal.julia,\
 org.objectweb.fractal.julia.asm,\
 org.objectweb.fractal.julia.control.attribute,\
 org.objectweb.fractal.julia.control.binding,\
 org.objectweb.fractal.julia.control.content,\
 org.objectweb.fractal.julia.control.lifecycle,\
 org.objectweb.fractal.julia.control.name,\
 org.objectweb.fractal.julia.factory,\
 org.objectweb.fractal.julia.loader,\
 org.objectweb.fractal.julia.logger,\
 org.objectweb.fractal.julia.type,\
 org.objectweb.fractal.rmi.registry,\
 org.objectweb.fractal.rmi,\
 org.objectweb.fractal.rmi.io,\
 org.objectweb.fractal.rmi.stub,\
 org.objectweb.fractal.jonathan,\
 org.objectweb.jonathan.apis.binding,\
 org.objectweb.jonathan.apis.kernel,\
 org.objectweb.jonathan.apis.presentation,\
 org.objectweb.jonathan.apis.protocols,\
 org.objectweb.jonathan.apis.protocols.ip,\
 org.objectweb.jonathan.apis.resources,\
 org.objectweb.jonathan.apis.stub_factories,\
 org.objectweb.jonathan.libs.helpers,\
 org.objectweb.jonathan.libs.kernel,\
 org.objectweb.jonathan.libs.protocols.tcpip,\
 org.objectweb.jonathan.libs.resources,\
 org.objectweb.jonathan.libs.resources.tcpip,\
 *

1.4. Build the bundle

You just have to launch the command 'mvn install'. The bundle will be created, added in your local Maven repository and the repository.xml will be created or updated (in ${user_home}/.m2/repository/repository.xml)

$ mvn install
...
[INFO] [install:install]
[INFO] Installing xxx/target/org.ow2.jasmine.jade.wrapper.apache-2.1.0-SNAPSHOT.jar  
to ~/.m2/repository/org/ow2/jasmine/jade/wrapper/org.ow2.jasmine.jade.wrapper.apache/2.1.0-SNAPSHOT/org.ow2.jasmine.jade.wrapper.apache-2.1.0-SNAPSHOT.jar
[INFO] [bundle:install]
[INFO] Created ~/.m2/repository/repository.xml
[INFO] Parsing ~/.m2/repository/repository.xml
[INFO] Writing OBR metadata
...

1.5. References

2. Contact

Now, for questions, ...

Enjoy.