2011-06-28 5 views
3

プロジェクトのバンドルを実行するためのOSGiコンテナを含むスタンドアロンのアーカイブを作成したいと考えています。目的は、アーカイブをダウンロードし、展開して、すぐに起動できるようにすることです。依存関係を自分のフォルダに展開しないMavenアセンブリを作成するにはどうしたらいいですか?

私はMavenアセンブリプラグインを使用してアーカイブを作成しています。以下のアセンブリ・ディスクリプタとApache Karaf上の単一の依存関係で、私は私のアーカイブには、以下の構造を得る:

 
+-apache-karaf-2.2.1 
    | 
    +-bin 
    +-demos 
    ... etc .. 

私はアンパック依存のベースディレクトリを削除したい場合は、一番上に自分のベースディレクトリを持っており、一部のフォルダ(例:demos)を除外し、自分のバンドルと設定ファイルを追加します。私はアセンブリプラグインでそのすべてを行うことができないようですが、私は使用できる別のプラグインはありますか?ここで

は私のアセンブリ・ディスクリプタです:私は、少なくとも右のレベルの数を持ちたいのでincludeBaseDirectoryのみfalseに設定されていることを

<assembly> 
    <id>dist-full</id> 
    <formats> 
    <format>tar.gz</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <dependencySets> 
    <dependencySet> 
     <unpack>true</unpack> 
     <useProjectArtifact>false</useProjectArtifact> 
     <useTransitiveDependencies>false</useTransitiveDependencies> 
    </dependencySet> 
    </dependencySets> 
</assembly> 

注、私はちょうど開梱後のものの名前を変更する必要があります。基本ディレクトリを保持し、依存関係の基底を取り除く方がよいでしょう。

答えて

2

maven-dependency-pluginを使用して依存関係を展開し、アセンブリ記述子にfileSetsを使用します。そのような:

のpom.xml:

<project> 
<!-- ... --> 

<dependencies> 
    <dependency> 
    <groupId>org.apache.karaf</groupId> 
    <artifactId>apache-karaf</artifactId> 
    <version>2.2.1</version> 
    <type>tar.gz</type> 
    </dependency> 
</dependencies> 

<!-- ... --> 

<build> 
    <plugins> 
    <plugin> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <executions> 
     <execution> 
      <id>prepare-runtime</id> 
      <goals> 
      <goal>unpack-dependencies</goal> 
      </goals> 
      <configuration> 
      <excludeTransitive>true</excludeTransitive> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
    <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <executions> 
     <execution> 
      <id>distribution-package</id> 
      <phase>package</phase> 
      <goals> 
      <goal>single</goal> 
      </goals> 
      <configuration> 
      <descriptor>assembly.xml</descriptor> 
      </configuration> 
     </execution> 
     </executions> 
    </plugin> 
    </plugins> 
</build> 

<!-- ... --> 
</project> 

assembly.xml:

<assembly> 
    <id>dist-full</id> 
    <formats> 
    <format>tar.gz</format> 
    </formats> 
    <baseDirectory>${groupId}.${artifactId}-${version}</baseDirectory> 
    <fileSets> 
    <fileSet> 
     <directory>target/dependency/apache-karaf-2.2.1</directory> 
     <outputDirectory /> 
     <includes> 
     <include>bin/**</include> 
     <include>lib/**</include> 
     <include>etc/**</include> 
     <include>deploy/**</include> 
     <include>system/**</include> 
     </includes> 
    </fileSet> 
    </fileSets> 
</assembly> 
関連する問題