Create a junit exclusion dynamically

The following configuration works:

test {
  useJunitPlatform {
    excludeTags 'a', 'b', 'c'

But I can’t seem to work out how to compute the list during configuration. I have a property, I can tokenize that property into a list, but I can’t seem to pass a list to excludeTags. I also tried making it a Junit expression dynamically ("a|b|c") but that didn’t seem to work either.

That’s why I majorly prefer Kotlin DSL where you have nice type-safety and amazing IDE support. :wink:

excludeTags is defined as public JUnitPlatformOptions excludeTags(String... excludeTags), so what you need is a String[]. So just add as String[] after your String list and it should work.

Thank you, I’ll give that a try. Moving to the Kotlin DSL for Gradle is on my short-to-medium term todo list. Pointers to good resources most graciously accepted.

Good resources for what? Kotlin DSL? In the Gradle Userguide you can switch for any example between Gradle and Kotlin DSL.

That’s where I’ll start, I suppose. Learning Kotlin and the Kotlin DSL at the same time is bound to lead to some confusion on my part. Despite years of working with the Gradle DSL in Groovy, I still get frustrated routinely by my inability to find answers to practical questions (like the one I asked in this thread, or the one I asked a few days ago about the test executor abruptly terminating).

Maybe this is partly because I find some aspects of Groovy just a bit weird. Perhaps Kotlin will be easier to grok. Anyway, thank you for taking the time to point me in the right direction. I do appreciate it.

Always happy to help and give you something back for your great work on DocBook, XProc, and so on. :slight_smile: