2013-08-09 4 views
16

私はgradleで設定された統合テストソースを持っており、それは私のメインクラスがコンパイルされているかどうかに依存します。あるソースセットを他のものに依存させる

integrationTestClasses.dependsOn 'classes' 

これはこれを行う方法ですか、またはソースセットの依存関係を自動的に設定する方法はありますか?私のconfigurationsブロックでは、私はすでに何が不足しているか

integrationTestCompile { extendsFrom testCompile } 
integrationTestRuntime { extendsFrom integrationTestCompile, testRuntime } 

答えて

23

を持っている:場所に、タスクの依存関係を自動的に確立する必要があります。これにより

dependencies { 
    integrationTestCompile sourceSets.main.output 
} 

+0

ありがとう、ピーター。私はそれを試してみましょう。 –

+0

それはうまくいった、ありがとう。私がメイン出力とテスト出力の両方に依存したいのであれば、テストはすでにメインに依存しているので、テスト依存性を宣言するだけでいいですか?それは私が見ているが確認したい動作であるようです。 –

+0

これは*正確に*あなたがここで何を意味するかによって決まります。 'sourceSets.test.output'は' sourceSets.main.output'を含みません。 –

1

sourceSetsを定義するときに依存関係を確立することもできます。これは、「生成」のsourceSetに依存する「メイン」のsourceSetセットアップに働いた:

// Default sourceSets already created by the java plugin: src/main and src/test 
// Default content for each sourceSet: /java and /resources 
sourceSets { 
    // Adding src/generated 
    generated 
    // Setting src/main to depend on the dependencies and output of src/generated 
    main { 
     compileClasspath += generated.compileClasspath + generated.output 
    } 
} 

同じ原理は、「メイン」に依存するように設定「integrationTest」に動作するはずです。

関連する問題