How to include to jar strictly only specific artifacts?

(aleksg) #1

I try to assemble jar file

jar {
manifest {
attributes ‘Implementation-Title’: ‘Gradle Jar File Example’,
‘Implementation-Version’: version
baseName = + '-all’
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

And I see inside of it a lot of libraries which should not be included there.
How correctly I can point Gradle what exactly libraries I want to see inside of jar along with my main code?

(Pierre) #2


If you want to build your own jar manually, I’d use configurations.runtime.collect and make use of compileOnly configuration to fetch dependencies required only at compile time.

Or you can use the application plugin which is doing the job for you behind the curtain.

(aleksg) #3

I used com.github.jengelman.gradle.plugins:shadow:2.0.1 plugin. It seems works fine.