Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titlepom demo.service-bundle
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <properties>
    <bundle.symbolicName>demo.service-bundle</bundle.symbolicName>
    <bundle.namespace>demo.service</bundle.namespace>
    <commons.log>1.1</commons.log>
  </properties>

  <modelVersion>4.0.0</modelVersion>
  <groupId>demo.service</groupId>
  <artifactId>demo.service-bundle</artifactId>
  <version>0.1</version>

  <name>${bundle.symbolicName} [${bundle.namespace}]</name>

  <packaging>bundle</packaging>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <!--
       | example additional resource entries, useful when building Eclipse RCP applications
      -->
      <resource>
        <directory>.</directory>
        <includes>
          <include>plugin.xml</include>
          <include>plugin.properties</include>
          <include>icons/**</include>
        </includes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.ops4j</groupId>
        <artifactId>maven-pax-plugin</artifactId>
        <version>1.4</version>
        <!--
           | enable improved OSGi compilation support for the bundle life-cycle.
           | to switch back to the standard bundle life-cycle, move this setting
           | down to the maven-bundle-plugin section
          -->
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>1.4.3</version>
        <!--
         | the following instructions build a simple set of public/private classes into an OSGi bundle
        -->
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
            <Bundle-Version>${pom.version}</Bundle-Version>
            <Export-Package>${bundle.namespace};version="${pom.version}"</Export-Package>
            <Private-Package>${bundle.namespace}.impl.*</Private-Package>
            <Include-Resource>src/main/resources</Include-Resource>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi_R4_core</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi_R4_compendium</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
        <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging-api</artifactId>
		<version>${commons.log}</version>
		<scope>provided</scope>
    </dependency>
  </dependencies>

</project>

...

Prior to run/launch the command generating the MANIFEST file, you must modify the pom.xml file in order to allow the OSGI bundle to import/use the services classes : demo.service

Code Block
xml
xml
titlepom demo.camel-bundle
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <properties>
    <bundle.symbolicName>demo.camel-bundle</bundle.symbolicName>
    <bundle.namespace>demo.camel</bundle.namespace>
  </properties>

  <modelVersion>4.0.0</modelVersion>
  <groupId>demo.camel</groupId>
  <artifactId>demo.camel-bundle</artifactId>
  <version>0.1</version>

  <name>${bundle.symbolicName} [${bundle.namespace}]</name>

  <packaging>bundle</packaging>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <!--
       | example additional resource entries, useful when building Eclipse RCP applications
      -->
      <resource>
        <directory>.</directory>
        <includes>
          <include>plugin.xml</include>
          <include>plugin.properties</include>
          <include>icons/**</include>
          <include>META-INF/*</include>
        </includes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.ops4j</groupId>
        <artifactId>maven-pax-plugin</artifactId>
        <version>1.4</version>
        <!--
           | enable improved OSGi compilation support for the bundle life-cycle.
           | to switch back to the standard bundle life-cycle, move this setting
           | down to the maven-bundle-plugin section
          -->
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>1.4.3</version>
        <!--
         | the following instructions build a simple set of public/private classes into an OSGi bundle
        -->
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
            <Bundle-Version>${pom.version}</Bundle-Version>
            <Import-Package>demo.service;version="${pom.version}"</Import-Package>
            <Include-Resource>src/main/resources</Include-Resource>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi_R4_core</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi_R4_compendium</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>demo.service</groupId>
      <artifactId>demo.service-bundle</artifactId>
      <version>${pom.version}</version>
    </dependency>
  </dependencies>

</project>

...