2

「bnd-maven-plugin」を使用して OSGi アプリケーションを開発してい ます https://github.com/bndtools/bnd/tree/master/maven/bnd-maven-plugin

私のプロジェクトには、maven を介して参照される多くのサードパーティの jar があります。

「maven install」を使用して jar バンドルを作成すると取得され、felix にデプロイすると、他の依存するサード パーティの jar が解決されません。

「maven-bundle-plugin」で動作してい ます http://www.lucamasini.net/Home/osgi-with-felix/creating-osgi-bundles-of-your-maven-dependencies

以下に示す「 bnd-maven-plugin 」を含むPOMファイル:

<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>XYZ.Models</groupId>
    <artifactId>XYZ.Models</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <archive>

                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

以下は「 maven-bundle-plugin」の POM の動作です。

<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>XYZ.Models</groupId>
    <artifactId>XYZ.Models</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
            <scope>provided</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>create-osgi-bundles-from-dependencies</id>
            <build>
                <directory>${basedir}/bundles</directory>
                <plugins>

                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <version>2.0.1</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>wrap-my-dependency</id>
                                <goals>
                                    <goal>wrap</goal>
                                </goals>
                                <configuration>
                                    <wrapImportPackage>;</wrapImportPackage>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
4

2 に答える 2

0

上記のように、bnd-maven-plugin について正しく言及してください。bndtoolsおよび - wcm.ioから参照を取得することもできますが 、たとえば、役立つ場合は数行を追加するだけです。

 <configuration>
     <bnd><![CDATA[
         Include-Resource: <EXAMPLE-GROUP-ID>*.jar;<ANOTHER>.*;
     ]]></bnd>
</configuration>

必要に応じてワイルドカードを使用できます。例を追加しました。

于 2020-12-17T16:48:44.837 に答える