I have a multi-project build where subprojects can be dependent on each other. Some of these projects have integration tests that are separate from the regular unit tests. A simple example script might be:
def integrationTestConfig = {
configurations {
integrationTestCompile
integrationTestRuntime
}
sourceSets {
integrationTest {
java.srcDir file('src/integrationTest/java')
resources.srcDir file('src/integrationTest/resources')
}
}
dependencies {
integrationTestCompile sourceSets.main.output
integrationTestCompile configurations.testCompile
integrationTestCompile sourceSets.test.output
integrationTestRuntime configurations.testRuntime
}
task(type: Test, 'integrationTest') {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
}
}
project(":a") {
apply plugin: "java"
configure(project, integrationTestConfig)
}
project(":b") {
apply plugin: "java"
configure(project, integrationTestConfig)
dependencies {
compile project(":a")
}
}
project("c") {
apply plugin: "java"
configure(project, integrationTestConfig)
dependencies {
compile project(":b")
}
}
The catch is that the integration tests in “:c” are dependent on compile integration test code in “:b” and “:a”. I’d like to add code to integrationTestConfig to automatically adds this functionality.
Any suggestions on how to do this?