How to include Maven dependencies in Manifest file

那年仲夏 提交于 2019-12-12 03:24:34

问题


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.

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

UPDATE According to the answer I used the Apache Felix

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>

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?


回答1:


Personally, I would generate the MANIFEST.MF file with Apache Felix Maven Bundle Plugin

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

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>

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



来源:https://stackoverflow.com/questions/38635488/how-to-include-maven-dependencies-in-manifest-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!