What is the best way to combine all of my .class files & my jar dependencies into a single jar?

I’d like to combine all of my .class files and my jar dependencies into a single jar file (so I can deploy a single file & run my app using java -jar app.jar).

What is the easiest way to do this with gradle?

Do I need to write a task to copy all the .classfiles into a single directory & then jar it up with the jar task? If so, is there an example that gets me part of the way there?

Thanks, Neil

I recommend to use the (third-party) ‘gradle-one-jar’ plugin.

I’ve been playing with the Shadow plugin (https://github.com/johnrengelman/shadow) this week and it seems to work pretty well. If you do try it, make sure you run ‘gradle knows’.

Thanks, I’ll look at both.

Neil

P.S. Chris, you are right. ‘gradle knows’ is a good target!