How to create an exploded war with Kotlin DSL?


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

You can do something like this in kotlin for what you have listed:

// Exploded war files
val explodedWar by tasks.register<Copy>("explodedWar") {
tasks.war {