Migrate existing Maven Project into an OSGI Bundle
Posted
by
user1706291
on Stack Overflow
See other posts from Stack Overflow
or by user1706291
Published on 2012-10-05T09:36:00Z
Indexed on
2012/10/05
9:37 UTC
Read the original article
Hit count: 231
i am new to the whole OSGi stuff and my task is to create an OSGi Bundle out from an exisitng maven project.
To get started i decided to pick the smallest part and starting with it:
Here is the pom.xml
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>
<parent>
<artifactId>cross</artifactId>
<groupId>net.sf.maltcms</groupId>
<version>1.2.12-SNAPSHOT</version>
</parent>
<artifactId>cross-main</artifactId>
<packaging>jar</packaging>
<name>cross-main</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-event</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-exception</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-main-api</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.6.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-math</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-all</artifactId>
<version>8.0.249</version>
</dependency>
<dependency>
<groupId>net.sf.mpaxs</groupId>
<artifactId>mpaxs-spi</artifactId>
<version>1.6.10</version>
</dependency>
<dependency>
<groupId>net.sf.mpaxs</groupId>
<artifactId>mpaxs-server</artifactId>
<version>1.6.10</version>
</dependency>
</dependencies>
I did some research and found the Apache Bundle Plugin for maven and changed the pom to this
<packaging>bundle</packaging>
and added
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
mvn clean install went fine and i got a jar file containing the manifest, but of course the bundle could not be resolved
BundleException: The bundle "cross-main_1.2.12.SNAPSHOT [30]" could not be resolved. Reason: Missing Constraint: Import-Package: com.db4o; version="[8.0.0,9.0.0)
To make a long story short: What are the possibiliteis to migrate a maven application into an OSGi Bundle?
Espacially how to manage the dependencys
© Stack Overflow or respective owner