2011-11-21 19 views
5

テストクラスとテストの依存関係を含むjar(ビルド済み)をビルドする方法を教えてください。依存関係とテストの依存関係を持つjarを作成する

「main」クラスの依存関係と依存関係を持つjarを(アセンブリプラグインを使用して)作成する方法を知っていますが、テストクラスとテストの依存関係が必要です。

私はjarプラグインを使ってテストクラスでjarファイルを作成できますが、これにはテストの依存関係は含まれていません。

TIA

答えて

1

おそらく、Mavenの依存性 - プラグインを組み合わせることにより達成することができます:アセンブリのプラグインとcopyDependencies。

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <executions> 
    <execution> 
     <id>copy-dependencies</id> 
     <phase>process-resources</phase> 
     <goals> 
     <goal>copy-dependencies</goal> 
     </goals> 
     <configuration> <!-- by default all scopes are included --> 
     <!-- copy all deps to target/lib --> 
     <outputDirectory>${project.build.directory}/lib</outputDirectory> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 
<plugin> 
    <artifactId>maven-assembly-plugin</artifactId> 
    ... 
</plugin> 

あなたの記述:

<assembly> 
    <fileSets> 
    <fileSet> 
     <directory>${project.build.directory}/lib</directory> 
     <outputDirectory>/</outputDirectory> 
     <includes> 
     <include>*.*</include> 
     </includes> 
    </fileSet> 
    </fileSets> 
</assembly> 
+0

おかげで、これはおけば動作します。私はアンパック依存関係を使用するようにクラスが必要です – thehpi

+0

あなたの歓迎 –

+0

アセンブリプラグインを調べた後、私はscope = testとunpack = trueでdependencySetを定義できます。これは実際に依存関係プラグインと同じです。 – thehpi

関連する問題