首页 > 解决方案 > How to specify class files with bnd

问题描述

I already successfully used the standalone bnd tool to create an OSGi bundle from a jar file.

Now I would like to create a bundle starting from .class files. By looking at some of the official bnd documentation I couldn't find anything to do this. I guess I'm looking for something like -classpath: output.jar that could work for .class files.

标签: javaosgibnd

解决方案


If I understood what you are trying to do, one option could be to set up a maven project and take advantage of the bnd-maven-plugin as described here. Basically, it is enough to add the following snippet in the build/plugins section of your pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
        </archive>
    </configuration>
</plugin>
<plugin>
    <groupId>biz.aQute.bnd</groupId>
    <artifactId>bnd-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>bnd-process</goal>
            </goals>
        </execution>
    </executions>
</plugin>

For a complete example of a maven-based approach you can refer to the OSGi enRoute website: https://enroute.osgi.org/Tutorial/


推荐阅读