Skip to content
Advertisement

Custom test source set with Gradle Kotlin DSL and Intellij

My project is using Gradle with Kotlin DSL for building. I now want to add a custom sourceset used for testing. The relevant code looks as follows:

JavaScript

By using that, I get another module in Intellij, which is treated as source module. I also tried the following to mark it as test module:

JavaScript

However, if I then do a ./gradlew clean idea and open the project using the generated files (normally I import my projects from Gradle), the system-test folder isn’t treated as source module at all.

Anyone having experience with declaring a custom sourceset with Kotlin DSL AND marking it as test module?

EDIT: I now created a sample Gradle project using Groovy and there it worked without problems with using the following code (which I guess is just the groovy version of my statements above):

JavaScript

So either I am getting the transformation to Kotlin DSL wrong or it is a bug on the Intellij side.

Advertisement

Answer

Seems like I got the Kotlin transformation wrong, it should be

JavaScript

Using this snippet, the testSourceDirs set is changed and the relevant sourceset marked as test module.

Advertisement