2011-07-18 9 views
11

私のKhatamiプロジェクトでは、mavenを使用してコンパイルを管理し、結果を実行可能なアーティファクトにパッケージ化しています:実行可能シェルスクリプトは実行可能ファイルを含むbin/瓶とそれに依存する瓶。私が何を意味するかを見てくださいhere。参考のためmaven-assembly-plugin MojoExecutionException with outputDirectory

は、ここではハタミのpom.xmlの凸部です:

 <plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <configuration> 
      <descriptors> 
      <descriptor>src/main/assembly/src.xml</descriptor> 
      </descriptors> 
      <archive> 
      <manifest> 
       <mainClass>${project.groupId}.Main</mainClass> 
      </manifest> 
      </archive> 
      <descriptorRefs> 
      <descriptorRef>jar-with-dependencies</descriptorRef> 
      </descriptorRefs> 
     </configuration> 
     </plugin> 

とフルsrc/main/assembly/src.xml

<assembly> 
    <id>dist</id> 
    <formats> 
    <format>tar.gz</format> 
    </formats> 
    <dependencySets> 
    <dependencySet> 
     <outputDirectory>bin</outputDirectory> 
    </dependencySet> 
    </dependencySets> 
    <fileSets> 
    <fileSet> 
     <directory>src/main/assembly</directory> 
     <outputDirectory>/</outputDirectory> 
     <includes> 
     <include>khatami</include> 
     </includes> 
     <fileMode>744</fileMode> 
     <lineEnding>unix</lineEnding> 
     <filtered>true</filtered> 
    </fileSet> 
    </fileSets> 
</assembly> 

とコンパイルしよう:私は障害で午前

$ mvn clean compile assembly:single 
[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building khatami 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ khatami --- 
[INFO] Deleting /home/blt/projects/com/carepilot/repos/khatami/target 
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ khatami --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] skip non existing resourceDirectory /home/blt/projects/com/carepilot/repos/khatami/src/main/resources 
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ khatami --- 
[INFO] Compiling 1 source file to /home/blt/projects/com/carepilot/repos/khatami/target/classes 
[INFO] 
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ khatami --- 
[INFO] Reading assembly descriptor: src/main/assembly/src.xml 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.721s 
[INFO] Finished at: Mon Jul 18 13:58:30 EDT 2011 
[INFO] Final Memory: 8M/123M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project khatami: Failed to create assembly: Error adding file 'com.carepilot.khatami:khatami:jar:1.0-SNAPSHOT' to archive: /home/blt/projects/com/carepilot/repos/khatami/target/classes isn't a file. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

+1

どのようにあなたのMavenビルドを実行していますか?コマンドラインから、またはIDEの中から> –

+0

コマンドライン。最後のコードリストには '' $ ''で始まる関連行が含まれています。 – troutwine

+0

eclipseでこのプロジェクトを使用したことがありますか、それをeclipse環境にインポートするためにプラグインを使用しましたか?これはいくつかの設定の問題のようです。私はこの種の問題を抱えていて、m2eclipseプラグインにそれを追跡しました。 (ちなみに)** –

答えて

14

エラー情報の関連部分は、それがファイルを期待しているとpackage目標はclean後に実行されていないので、それはそれを見つけることができません

Error adding file 'com.carepilot.khatami:khatami:jar:1.0-SNAPSHOT' to archive: 
/home/blt/projects/com/carepilot/repos/khatami/target/classes isn't a file. 

です。

mvn clean compile package assembly:singleを作成すると正常にビルドされます。

の目標をpackageフェーズに追加すると、自動的に構築されます。

<plugin> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <executions> 
    <execution> 
     <phase>package</phase> 
     <goals> 
     <goal>single</goal> 
     </goals> 
     <configuration> 
     <descriptors> 
      <descriptor>src/main/assembly/src.xml</descriptor> 
     </descriptors> 
     <archive> 
      <manifest> 
      <mainClass>${project.groupId}.Main</mainClass> 
      </manifest> 
     </archive> 
     <descriptorRefs> 
      <descriptorRef>jar-with-dependencies</descriptorRef> 
     </descriptorRefs> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 

上記の設定を変更するだけで発行できます。

mvn clean package 

assembly:single目標は、自動的に実行されます。

これを行うより良い方法は、これを手動で行う代わりにmaven-shade-pluginを使用することです。

3

あなたの問題:(:ハタミます。jar:1.0-SNAPSHOT com.carepilot.khatami)まだパッケージ化されていませんが、アセンブリの<dependencySet>の一部である

Error adding file 'com.carepilot.khatami:khatami:jar:1.0-SNAPSHOT' to archive: 
/home/blt/projects/com/carepilot/repos/khatami/target/classes isn't a file. 

は、プロジェクトの成果物があるため発生します。この問題を解決するには、<dependencySet><useProjectArtifact>false</useProjectArtifact>を追加してください。

アセンブリに含まれるプロジェクトのクラスファイルが必要な場合は、<fileSet>を使用して、ディレクトリtarget/classesを含めることができます。例えば

<assembly> 
    <id>dist</id> 
    <formats> 
    <format>tar.gz</format> 
    </formats> 
    <dependencySets> 
    <dependencySet> 
     <useProjectArtifact>false</useProjectArtifact> 
     <outputDirectory>bin</outputDirectory> 
    </dependencySet> 
    </dependencySets> 
    <fileSets> 
    <fileSet> 
     <directory>src/main/assembly</directory> 
     <outputDirectory>/</outputDirectory> 
     <includes> 
     <include>khatami</include> 
     </includes> 
     <fileMode>744</fileMode> 
     <lineEnding>unix</lineEnding> 
     <filtered>true</filtered> 
    </fileSet> 
    </fileSets> 
</assembly> 

別のオプションは、packaging後フェーズにアセンブリを取り付けることであろう。