I am trying to embed some JARs into an OSGI bundle which do not have a corresponding OSGI bundle so that other OSGI bundles can reference them.
I have followed many suggestions but nothing worked. My last attempt is based on: <Export-Package> for all resources using maven-bundle-plugin
When I examine the resulting OSGI package it does not contain the expected embedded jar:
META-INF
META-INF\MANIFEST.MF
META-INF\maven
META-INF\maven\com.mycompany
META-INF\maven\com.mycompany\osgi-bundle-test
META-INF\maven\com.mycompany\osgi-bundle-test\pom.properties
META-INF\maven\com.mycompany\osgi-bundle-test\pom.xml
Here is my POM.XML:
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.1</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>*</Export-Package>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
Here is a snippet from mvn clean install:
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (copy-dependencies) @ osgi-bundle-test ---
[INFO] Copying guava-18.0.jar to <local-dir>\target\dependency\guava-18.0.jar
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ osgi-bundle-test ---
[INFO] Building jar: <local-dir>\target\osgi-bundle-test-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ osgi-bundle-test ---
[INFO] Installing <local-dir>\target\osgi-bundle-test-0.0.1-SNAPSHOT.jar to <repo-dir>\com\mycompany\osgi-bundle-test\0.0.1-SNAPSHOT\osgi-bundle-test-0.0.1-SNAPSHOT.jar
[INFO] Installing <local-dir>\pom.xml to <repo-dir>\com\mycompany\osgi-bundle-test\0.0.1-SNAPSHOT\osgi-bundle-test-0.0.1-SNAPSHOT.pom
Content of MANIFEST.MF:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: xxxx
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_65
Please help.