我可以在gradle项目中使用备用主sourceSet吗?

时间:2015-04-21 23:38:37

标签: gradle source-sets

我正在使用主要sourceSet中的一组测试和代码编写一个训练任务。我还想在一个单独的sourceSet中提供一个示例答案,该源集可以使用单独的任务运行。有没有办法在两个不同的主要源集上运行相同的测试集?

1 个答案:

答案 0 :(得分:0)

事实证明,这可以通过从运行时类路径中删除主sourceSet来实现,如下所示:

task testAnswers(type: Test) {
    description = "Runs tests against the example answer"                       
    testClassesDir = sourceSets.answers.output.classesDir                       
    classpath -= sourceSets.main.runtimeClasspath                               
    classpath += sourceSets.answers.runtimeClasspath
}