2009-09-30 3 views
20

Maven gurusへ: Java以外のプロジェクト成果物(.NET)を単一のzipファイルにパッケージ化しようとしています。 - 私はそれ以外の場合は作成され、無駄なjarファイルを取り除くために<packaging>pom</packaging>にそれを変更し[INFO] Cannot find lifecycle mapping for packaging: 'zip'. Component descriptor cannot be found in the component repository: org.apache.mav en.lifecycle.mapping.LifecycleMappingzip. OK、大したことない:私は<packaging>zip</packaging>を圧縮するために私のPOM包装を変更した場合、私はこのエラーメッセージが表示されますMavenでフラットなジップアセンブリを作成しています

:私は2つの問題を抱えていますターゲットディレクトリ内

私の主な問題は、私がZIPにパッケージ化しているファイルがいくつかのディレクトリに入れ子になっていますが、これらをZIPのトップディレクトリに入れる必要があることです。ここに私のアセンブリファイルです:

<assembly> 
    <id>bin</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <fileSets> 
    <fileSet> 
     <directory>${basedir}/${project.artifactId}</directory> 
     <includes> 
     <include>**/Bin/Release/*.dll</include> 
     <include>**/Bin/Release/*.pdb</include> 
     </includes> 
    </fileSet> 
    </fileSets> 
</assembly> 

私はこれを実行

- 私は、ZIPファイルを取得しますが、ファイルはCで始まるネストされます:\フルパスが続きます。たぶん私はちょうどアリのzipをantrun使用して実行する必要が

<plugin> 
<artifactId>maven-assembly-plugin</artifactId> 
<configuration> 
    <descriptors> 
     <descriptor>assembly.xml</descriptor> 
    </descriptors> 
</configuration> 
<executions> 
    <execution> 
     <id>zip</id> 
     <phase>package</phase> 
     <goals> 
      <goal>single</goal> 
     </goals> 
    </execution> 
</executions> 

: - あなたのアイデアを与えるためにプロジェクトには、それは次のような構造 ProjectFoo\ProjectFoo\subproject1\Bin\Release\foo.dllにバイナリだダンプと私はZIP\foo.dll

を必要とすることはここでは、アセンブリプラグインの設定です仕事?

答えて

27

これまで見てきたように、ジップパッケージングタイプはありません。したがって、あなたが選択したように、pomパッケージを使用することは理にかなっています。

アセンブリプラグインの処理で少しの穴が発生しました。これを解決するには、アセンブリ内に複数のfileSetsを<outputDirectory>/<outputDirectory>で指定します.1つは含めるディレクトリごと、1つはPITA、おそらく許容できる解決策ではありません。

Antのコピータスクを使用して、すべてのDLLをステージングディレクトリにコピーし、そのディレクトリをアセンブリに含める方法があります。

次の設定は、行う必要があり、あなたがしているものの後:

antrun・プラグイン設定:

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.3</version> 
    <executions> 
     <execution> 
     <phase>process-resources</phase> 
     <configuration> 
      <tasks> 
      <copy todir="${project.build.directory}/dll-staging"> 
       <fileset dir="${basedir}/${project.artifactId}"> 
       <include name="**/Bin/Release/*.dll"/> 
       <include name="**/Bin/Release/*.pdb"/> 
       </fileset> 
       <flattenmapper/> 
      </copy> 
      </tasks> 
     </configuration> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 

アセンブリ:私がまさに必要

<assembly> 
    <id>bin</id> 
    <formats> 
    <format>zip</format> 
    </formats> 
    <fileSets> 
    <fileSet> 
     <directory>${project.build.directory}/dll-staging</directory> 
     <outputDirectory>/</outputDirectory> 
     <includes> 
     <include>*.dll</include> 
     <include>*.pdb</include> 
     </includes> 
    </fileSet> 
    </fileSets> 
</assembly> 
+0

!リッチありがとう! – Bostone

+0

あなたは歓迎です –

+0

しかし、まだ1つの問題があります。 zipは、まだ "artifactId-Version"というタイプの1つのトップディレクトリを維持しています。 zipを解凍すると、すべてのファイルは '/'ではなく '/ Foo-1.0-SNAPSHOT /'になります。それでも、ファイルはターゲット/ dllステージングに正しくコピーされます – Bostone

関連する問題