How to create an exploded war with Kotlin DSL?

Greetings,

I need an exploded war and am trying to create a task to do it. I’ve scoured the internet and have only been able to find an old example in groovy. Unfortunately I am having trouble converting it to the kotlin dsl. If there is a newer/better way I’d be happy to hear about it.

Here is the sample groovy. How do I do this in the Kotlin DSL?

task explodedWar(type: Copy) {
    into "$buildDir/exploded"
    with war
}