2012-12-05 7 views
8

は、私は、以下の構成を持っている:コピー依存関係の目標の間にmaven-dependency-pluginを使用して、テストとコンパイルの間でアーティファクトを分割する方法はありますか?

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>2.6</version> 
    <executions> 
     <execution> 
      <id>analyze</id> 
      <goals> 
       <goal>analyze-only</goal> 
      </goals> 
      <configuration> 
       <failOnWarning>false</failOnWarning> 
      </configuration> 
     </execution> 
     <!--Copy the dependencies so ant build has the same versions--> 
     <execution> 
      <id>copy-dependencies</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-dependencies</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.basedir}/lib</outputDirectory> 
       <overWriteIfNewer>true</overWriteIfNewer> 
       <stripVersion>true</stripVersion> 
       <overWriteReleases>false</overWriteReleases> 
       <overWriteSnapshots>true</overWriteSnapshots> 
       <excludeTransitive>false</excludeTransitive> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

上記の構成は同じフォルダ上のすべてをダンプします。私は、テスト構成を追加することにより、テスト範囲を除いてみましたが、エラーを与える:

Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.6:copy-dependencies (copy-dependencies) on project pcgen: Can't exclude Test scope, this will exclude everything.

は、私は別のフォルダにコピーすることができるように残りの部分から、テストの依存関係を分離する方法はありますか?

+0

なぜしたいですか? Antの代わりにMavenを直接使用しないのはなぜですか? – khmarbaise

+1

私のコントロールからただの要件。現在、プロジェクトはANTからMavenに移行しており、移行が完了している間は両方を実行しておく必要があります。私はMavenで彼らの設定を作り直そうとしています。 – javydreamercsw

答えて

8

I tried excluding the test scope by adding the test configuration but gives an error

私はちょうど非常に異なる理由でこれを見つけましたが、私は両方の答えを見つけたと思います。たとえば、これを試してみてください。もちろん、現在のディレクトリにはpom.xmlが必要です。 2013年5月には

You shouldn't ever need to include or exclude two scopes at the same time because they are comprised of each other. The default is to include test scope, which includes everything. If you don't want any test dependencies or provided dependencies, then include runtime and exclude provided.

The scopes being interpreted are the scopes as maven sees them, not as specified in the pom. So the "test" scope includes everything, runtime includes compile but not provided etc.

includeScope documentation was updatedに:

mvn dependency:copy-dependencies \ 
-DincludeScope=runtime \ 
-DexcludeScope=provided \ 
-DoutputDirectory=target/war/WEB-INF/lib 

Maven Dependency Plugin Issue #128に書き込み、ブライアン・フォックス、と巨大な遅ればせながら感謝を

/** 
    * Scope to include. An Empty string indicates all scopes (default). 
    * The scopes being interpreted are the scopes as 
    * Maven sees them, not as specified in the pom. In summary: 
    * <ul> 
    * <li><code>runtime</code> scope gives runtime and compile dependencies,</li> 
    * <li><code>compile</code> scope gives compile, provided, and system dependencies,</li> 
    * <li><code>test</code> (default) scope gives all dependencies,</li> 
    * <li><code>provided</code> scope just gives provided dependencies,</li> 
    * <li><code>system</code> scope just gives system dependencies.</li> 
    * </ul> 
    * 
    * @since 2.0 
    */ 
@Parameter(property = "includeScope", defaultValue = "") 
protected String includeScope; 
0

実際に使用includeScope、テスト範囲は、すべて含まれてスコープは、それが失敗する理由です。

<includeScope>runtime</includeScope> 
関連する問題