DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| No Format |
|---|
<project> <modelVersion>4.0.0</modelVersion> <groupId>my-osgi-bundles</groupId> <artifactId>simple<<artifactId>examplebundle</artifactId> <packaging>bundle</packaging> <!-- (1) --> <version>1.0</version> <name>Example Bundle</name> <build> <plugins> <plugin> <!-- (2) START --> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Export-Package>com.my.company.api</Export-Package> <Private-Package>com.my.company.*</Private-Package> <BundleActivator>com.my.company.Activator</BundleActivator> </instructions> </configuration> </plugin> <!-- (2) END --> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.osgi.core</artifactId> <scope>provided</scope> </dependency> </dependencies> </project> |
Three Two main things to note: (1) the <packaging> specifier , and (2) the plugin and configuration specification, and (3) the <scope> specifier on the dependency. The org.osgi-3.0.jar is a compile-time dependency, but the scope specifier indicates that our OSGi container will provide the dependency at runtime so there is no need to embed the dependent jar into the bundle archive..there is no need to embed the dependent jar into the bundle archive.
Real-World Example
Consider this more real-world example using Felix' Log Service implementation. The Log Service project is comprised of a single package: org.apache.felix.log.impl. It has a dependency on the core OSGi interfaces as well as a dependency on the compendium OSGi interfaces for the specific log service interfaces. The following is its POM file:
| No Format |
|---|
<project>
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>felix</artifactId>
<version>0.8.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<name>Apache Felix Log Service</name>
<description>
This bundle provides an implementation of the OSGi R4 Log service.
</description>
<artifactId>org.apache.felix.log</artifactId>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.osgi.service.log</Export-Package>
<Private-Package>org.apache.felix.log.impl</Private-Package>
<BundleSymbolicName>${pom.artifactId}</BundleSymbolicName>
<BundleActivator>${pom.artifactId}.impl.Activator</BundleActivator>
<ExportService>org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService</ExportService>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
|