Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以在gradle项目中使用备用主源集吗?_Gradle_Source Sets - Fatal编程技术网

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

我可以在gradle项目中使用备用主源集吗?,gradle,source-sets,Gradle,Source Sets,我正在编写一个培训任务,在主源集中包含一组测试和代码。我还想在一个单独的源集中提供一个示例答案,它可以与一个单独的任务一起运行。有没有一种方法可以在两个不同的主源上运行相同的测试集?事实证明,可以通过从运行时类路径中删除主源集来实现这一点,如下所示: task testAnswers(type: Test) { description = "Runs tests against the example answer" testClas

我正在编写一个培训任务,在主源集中包含一组测试和代码。我还想在一个单独的源集中提供一个示例答案,它可以与一个单独的任务一起运行。有没有一种方法可以在两个不同的主源上运行相同的测试集?

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

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