The Gradle DSL for layer configuration currently uses layers twice:

bootJar {
    layers {
        layers "dependencies", "snapshot-dependencies", "application"
        …
    }
}

We'd like to simplify this to avoid the repetition of layers, hopefully to something like the following:

bootJar {
    layers("dependencies", "snapshot-dependencies", "application") {
       …
    }
}

Comment From: scottfrederick

Unfortunately the suggested syntax does not work because it's not possible to pass a variable-length list of strings followed by a closure. Moving the layer names to the outer layers would require wrapping the layer names in an explicit array initializer [ ... ], as in

bootJar {
    layers(["dependencies", "snapshot-dependencies", "application"]) {
       …
    }
}

This looks error prone, and the failure message provided by Gradle if the [] is omitted isn't very helpful.

Instead, we'll go with

bootJar {
    layers {
        layersOrder "dependencies", "snapshot-dependencies", "application"
        …
    }
}

Comment From: wilkinsona

Thanks, Scott. I agree on not using the [] syntax. I wonder if layerOrder would read better than layersOrder?