I am trying to add another module to my Kotlin project specifically for integration tests - living alongside the standard test
module creating by the kotlin plugin. Here is my current configuration to add the sourceset
:
sourceSets {
testIntegration {
java.srcDir 'src/testIntegration/java'
kotlin.srcDir 'src/testIntegration/kotlin'
resources.srcDir 'src/testIntegration/resources'
compileClasspath += main.output
runtimeClasspath += main.output
}
}
configurations {
provided
testCompile.extendsFrom provided
testIntegrationCompile.extendsFrom testCompile
testIntegrationRuntime.extendsFrom testRuntime
}
task testIntegration(type: Test) {
testClassesDirs = sourceSets.testIntegration.output.classesDirs
classpath = sourceSets.testIntegration.runtimeClasspath
}
This seems to work, however IntelliJ does not pick up the new source set as a test module. I can manually mark it, but it resets every time Gradle runs. This also means that Intellij fills in the Output Path
and not the Test Output Path
fields in the project structure settings.
To fix that the below configuration works:
apply plugin: 'idea'
idea {
module {
testSourceDirs += project.sourceSets.testIntegration.java.srcDirs
testSourceDirs += project.sourceSets.testIntegration.kotlin.srcDirs
testSourceDirs += project.sourceSets.testIntegration.resources.srcDirs
}
}
However, this seems to instruct IntelliJ that the Test Output Path
is \out\test\classes
which is the same as the standard 'test' module and causes conflict issues. I want it to keep the output path as the original \out\testIntegration\classes
which would have otherwise been used.
Is there any way to instruct IntelliJ to pick up this new test source set correctly and fill in the right output path?