Gradle 5.0 equivalent of the old "fat" jar technique

I’m trying to get the old 4.x tactic to create a fat jar working in 5.0. With the changes to configurations this no longer works. In particular I’d want a Kotlin DSL solution. This is the snippet I’m stuck on:

jar {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

What exactly are you stuck on? Do you just mean the syntax? I believe the Kotlin equivalent to that Groovy snippet is:

tasks.register<Jar>("jar") {
    from(Callable { configurations["compile"].map { if (it.isDirectory) it else zipTree(it) } })
}

I haven’t tested this.

Try using the runtimeClasspath or compileClasspath configuration. The compile configuration no longer gives the names that it used to give.

I’ll look into it. Pretty sure I did try that too but will check. What I was hitting was that the configurations were empty. I thought I read something about changes to configurations in light of task lazy loading work. I can’t find that reference now, but I do note the 5.0 broke older versions of the ShadowJar plugin so I feel like this is related.

Nice. Thanks, pulling together the two suggestions I got things working:

   from(Callable { configurations["runtimeClasspath"].map { if (it.isDirectory) it else zipTree(it) } })