希望有人可以帮我解决这个问题。我正在尝试使用maven-bundle-plugin从我的maven依赖项自动生成我的OSGi清单。我正在OSGi容器中安装一些依赖项,因为它们是在多个bundle中共享的。例如,Spring。我正在设置这些依赖项的范围(因为它们是在容器中提供的,而不是嵌入的)。但是,我无法让maven-bundle-plugin在清单的部分中包含这些依赖项。任何想法如何做到这一点?
<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>
<groupId>com.example.osgi.test</groupId>
<artifactId>spring-mvc-bundle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
<spring.osgi.version>1.2.1</spring.osgi.version>
</properties>
<!-- Module dependencies -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<!-- Other dependencies here... -->
</dependencies>
<!-- Build plugins + config -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>create-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
<configuration>
<supportedProjectTypes>
<supportedProjectType>war</supportedProjectType>
<supportedProjectType>jar</supportedProjectType>
<supportedProjectType>bundle</supportedProjectType>
</supportedProjectTypes>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
这很大程度上取决于您对这些依赖项的使用。如果它们与动态类加载一起使用,那么bnd工具不知道如何处理它们。因此,您需要将这些依赖项添加到配置部件的一部分。这样,除了已经找到的Imports外,它们还会作为Imports添加到您的Manifest。