这花了我一段时间才能弄清楚,在线资源也不是很好。所以我想记录我的解决方案。
这是一个简单的gradle构建脚本,除了主要和测试源集之外,还具有intTest源集:
apply plugin: "java"sourceSets { // Note that just declaring this sourceset creates two configurations. intTest { java { compileClasspath += main.output runtimeClasspath += main.output } }}configurations { intTestCompile.extendsFrom testCompile intTestRuntime.extendsFrom testRuntime}task intTest(type:Test){ description = "Run integration tests (located in src/intTest/...)." testClassesDir = project.sourceSets.intTest.output.classesDir classpath = project.sourceSets.intTest.runtimeClasspath}


