現在、私はOSGiベースのアプリケーションを開発中です(Felixを使用しています)。このプロジェクトでは、他のバンドルに応じてバンドルがあります。過去にはAntスクリプトを使ってすべてをコンパイルしてビルドしていましたが、今はこれを作成したいと思いますが、タスクはまったく簡単なことではありません。ここでMaven + OSGiバンドルの複雑化
私が持っているフォルダ構造です:
明らか+-shared
-- pom.xml
-- someProject
--- pom.xml
-- org.apache.felix
--- pom.xml
-- org.apache.activemq
--- pom.xml
-- org.apache.log4j
--- pom.xml
-- org.snake.yaml
--- pom.xml
-- ...
、ルートPOMは、ここですべてを構築することになって、そして個々のPOMは、単にバンドルを記述しています。私もMANIFEST.MF
各バンドル内のファイル(自動生成されていない)があります。共通のリポジトリから取得するのではなく、独自のリポジトリを持つことを望んでいると言わなければなりません。
今のところ、私はではありません。は、maven-bundle-pluginのようなプラグインを使用しています。私はこれを自分でしようとしています。しかし、私は多くの場合、package does not exist
エラーが多い、多くのエラーを取得します。したがって、私は何か間違っていると思う。フォーラムで見て回った後、多くの人がmaven-bundle-pluginを使っていることに気付きました。しかし、公式のウェブサイトは、ある時点まで私を助けてくれるかもしれません。
短いので、私は少なくともコンパイルできる機能pom.xml
を持っていたいと思います。また、自動的にMANIFEST.MF
が生成される場合がありますが、どうすればよいかわかりません。
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>shared</groupId>
<artifactId>shared.master</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>shared</groupId>
<artifactId>shared.cmd.felix</artifactId>
<name>shared.cmd.felix</name>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>shared</groupId>
<artifactId>org.apache.felix</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../org.apache.felix/felix.jar</systemPath>
</dependency>
<dependency>
<groupId>shared</groupId>
<artifactId>org.apache.log4j</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../org.apache.log4j/log4j-1.2.17.jar</systemPath>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-ClassPath>.</Bundle-ClassPath>
<Export-Package>shared.cmd.felix</Export-Package>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
とorg.apache.felix
のpom.xml
:
は、これまでのところ、私はこのpom.xml
(someProject1
の)を思い付いた
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>shared</groupId>
<artifactId>shared.master</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>shared</groupId>
<artifactId>org.apache.felix</artifactId>
<name>org.apache.felix</name>
<version>1.0.0</version>
</project>
と私が持っているMANIFEST.MF
です:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Shared Felix Console Extension
Bundle-SymbolicName: shared.cmd.felix
Bundle-Version: 1.0.0
Fragment-Host: shared.mw;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .,
bundle/system/org.apache.felix.gogo.runtime-0.10.0.jar
Export-Package: shared.cmd.ext
Import-Package: shared,
shared.cmd,
shared.comp,
shared.mw,
shared.sched,
shared.service,
org.apache.felix.service.command,
org.apache.log4j,
org.osgi.framework
Require-Bundle: org.apache.felix;bundle-version="1.0.0",
org.apache.activemq
しかし、私はエラーが発生します以下のような:私はmaven-bundle-pluginを利用できる状態にこれを変更したい場合は、どのようにそれは
今[ERROR] /shared/shared.cmd.felix/src/shared/cmd/ext/ListScheduledTasks.java:[11,40] package org.apache.felix.service.command does not exist
[ERROR] /shared/shared.cmd.felix/src/shared/cmd/ext/ListScheduledTasks.java:[15,19] cannot find symbol
だろうか?私はこの思い付いたが、これは私が上に持っているものに相当するかどうかを知りません。もっと重要な
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>shared</groupId>
<artifactId>shared.cmd.felix</artifactId>
<packaging>bundle</packaging>
<name>shared.cmd.felix</name>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.apache.felix</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>org.apache.log4j</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>${pom.groupId}</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>--WHAT TO PUT HERE?--</Export-Package>
<Private-Package>--WHAT TO PUT HERE?-</Private-Package>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>--WHAT TO PUT HERE?-</Bundle-Activator>
<Export-Service>--WHAT TO PUT HERE?-</Export-Service>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
と、私はそこにすべてのものを挿入する必要がありますか? Export-Service
などの一部をスキップできませんか?そして、私が上記で入力したローカルパスに何が起こったのですが、なぜプラグインにこれらがないのですか?自動的にそれらを見つけるか?
誰かが私を助けてくれますか?私はどんな貢献にも感謝します。
ありがとうございます。
開始する場合は、セットアップで表示される方がよい場合があります。その場合は、http://enroute.osgi.orgサイトからOSGiの多くの基本を学ぶことができます。基礎を習得した後は、まだそれを望むなら、mavenプロジェクトをセットアップするのはかなり簡単です。 –