1
我需要创建一个OSGi包包括依赖关系,我使用maven具组件插件,这是我的pom.xml构建OSGi包包括与Maven的组装插件依赖性
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>logstat</artifactId>
<packaging>bundle</packaging>
<name>Log Stat Demo</name>
<version>1.0</version>
<groupId>org.test</groupId>
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>yecht</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>activator.*,service.*,impl.*</Export-Package>
<Bundle-Activator>activator.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>activator.Activator</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我运行Maven构建,它创造了2瓶文件,一个具有依赖性和一个没有
但在一个与属地,MANIFEST.MF不包括OSGi的配置,如:
Manifest-Version: 1.0
Bnd-LastModified: 1392281245886
Build-Jdk: 1.6.0_45
Built-By: myname
Bundle-Activator: activator.Activator
Bundle-ManifestVersion: 2
Bundle-Name: test
Bundle-SymbolicName: org.wiperdog.logstat
Bundle-Version: 1.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: activator;uses:="org.osgi.framework";version="1.0.0",ser
vice;version="1.0.0",impl;uses:="org.osgi.framework,service";version="1
.0.0"
Import-Package: org.jruby.embed;version="[1.7,2)",org.jruby.embed.osgi;v
ersion="[1.7,2)",org.osgi.framework;version="[1.6,2)"
Tool: Bnd-2.1.0.20130426-122213
它只是有索姆e基本罐配置,不是OSGi捆绑:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_45
Main-Class: activator.Activator
那么,我该如何配置?
那么把你的依赖捆内(虽然是可能的,如果你的私人包)肯定是不推荐的。 OSGi全都是关于模块化的。为什么你想把所有的依赖关系放在包中? – codesalsa
是什么,为什么你用汇编插件的原因是什么? maven-bundle-plugin具有嵌入依赖功能。有了这一点,你可以控制,这包应该从嵌入式依赖出口。 –
谢谢,我希望把一些依赖类,因为我想在OSGi环境运行一些Ruby脚本和脚本需要使用log4j的从一些类,所以我需要包括类似:需要“org.apache.log4j.spi。 LoggingEvent所” – Ryo