如何在清单文件中包含Maven依赖项 [英] How to include Maven dependencies in Manifest file

查看:241
本文介绍了如何在清单文件中包含Maven依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用maven编译OSGI应用程序的插件.为了安装插件,OSGI应用程序应阅读有关插件依赖项的信息.此信息应在MANIFEST.MF文件中提供.我想知道的是如何使用Virgo Tooling生成正确的MANIFEST.MF文件.

I am developing a plugin for the OSGI application, using maven to compile. In order to install the plugin, the OSGI application should read the information about plugin dependencies. This information should be provided in the MANIFEST.MF file. What I'm wondering is how to use Virgo Tooling to generate a proper MANIFEST.MF file.

这些是我想包含在MANIFEST.MF 中的依赖项

These are the dependencies I would like to include in the MANIFEST.MF

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

UPDATE According to the answer I used the Apache Felix

我已添加到pom.xml

To the pom.xml I have added

<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文件,但清单仅包含以下信息

downloaded the maven-bundle.jar and executed the command mvn org.apache.felix:maven-bundle-plugin:manifest which produced the .jar file with the manifest, but manifest contained only following infromation

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

有什么想法我做错了吗?

Any ideas what I did wrong?

推荐答案

我个人将使用尝试在项目的pom.xml文件的插件中添加一些配置.

Try to add some configuration to the plugin in the project's pom.xml file.

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

Here's a start, but you should read the documentation and find the correct instructions that will fit your precise need. It would be helpful if you could provide an example of MANIFEST.MF file.

<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>

使用这种配置,将在'generate-resources'阶段生成MANIFEST.MF.

With this kind of config, the MANIFEST.MF will be generated during 'generate-resources' phase.

这篇关于如何在清单文件中包含Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆