如何在清单文件中包含Maven依赖项

时间:2016-07-28 11:49:00

标签: java maven osgi eclipse-virgo

我正在为OSGI应用程序开发一个插件,使用maven进行编译。为了安装插件,OSGI应用程序应该读取有关插件依赖性的信息。应在MANIFEST.MF文件中提供此信息。我想知道的是如何使用Virgo Tooling生成一个合适的MANIFEST.MF文件。

这些是我想要包含在MANIFEST.MF 中的依赖项 enter image description here

更新根据答案,我使用了Apache Felix

到我添加的pom.xml

<plugin>
  <artifactId>maven-jar-plugin</artifactId>
  <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>
  <executions>
    <execution>
      <id>bundle-manifest</id>
      <phase>process-classes</phase>
      <goals>    
        <goal>manifest</goal>
      </goals>   
    </execution>
  </executions>
</plugin>

下载maven-bundle.jar并执行命令mvn org.apache.felix:maven-bundle-plugin:manifest,该命令生成带有清单的.jar文件,但清单仅包含以下信息

Manifest-Version: 1.0
Implementation-Vendor: The Apache Software Foundation
Implementation-Title: Maven Bundle Plugin
Implementation-Version: 3.2.0
Implementation-Vendor-Id: org.apache.felix
Built-By: cziegeler
Build-Jdk: 1.7.0_80
Specification-Vendor: The Apache Software Foundation
Specification-Title: Maven Bundle Plugin
Created-By: Apache Maven 3.3.9
Specification-Version: 3.2.0
Archiver-Version: Plexus Archiver

任何想法我做错了什么?

1 个答案:

答案 0 :(得分:2)

就个人而言,我会使用Apache Felix Maven Bundle Plugin

生成MANIFEST.MF文件

尝试在项目的pom.xml文件中为插件添加一些配置。

这是一个开始,但您应该阅读文档并找到符合您确切需求的正确说明。如果您能提供MANIFEST.MF文件的示例,将会很有帮助。

<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.2.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
                </instructions>
            </configuration>
            <executions>
                <execution>
                    <id>generate-manifest</id>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                    <phase>generate-resources</phase>
                </execution>
            </executions>
        </plugin>

使用这种配置,MANIFEST.MF将在&quot; generate-resources&#39;生成期间生成。相。

相关问题