I also needed to do something similar, and I was not able to get what Guus and Stigch offered to work, but close enough with their help to get this work (Guus example exploded on closing dependencies { compile { extendsFrom myLibs }} for me.
apply plugin: 'groovy' repositories { mavenCentral() } configurations { // custom config of files we want to include in our fat jar that we send to hadoop includeInJar } dependencies { includeInJar 'org.codehaus.groovy:groovy:1.8.6' configurations.compile.extendsFrom(configurations.includeInJar) } jar { into('lib') { println "includeInJar: " + configurations.includeInJar.collect { File file -> file } from configurations.includeInJar } }
Then running the gradle jar and looking at the created jar gives me this result, showing that I get the jar file with groovy, as well as all the jars that it depends on inside the "thick jar":
% gradle jar includeInJar: [/Users/tnaleid/.gradle/caches/artifacts-8/filestore/org.codehaus.groovy/groovy/1.8.6/jar/553ca93e0407c94c89b058c482a404427ac7fc72/groovy-1.8.6.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/antlr/antlr/2.7.7/jar/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/asm/asm/3.2/jar/9bc1511dec6adf302991ced13303e4140fdf9ab7/asm-3.2.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/asm/asm-tree/3.2/jar/cd792e29c79d170c5d0bdd05adf5807cf6875c90/asm-tree-3.2.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/asm/asm-commons/3.2/jar/e7a19b8c60589499e35f5d2068d09013030b8891/asm-commons-3.2.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/asm/asm-util/3.2/jar/37ebfdad34d5f1f45109981465f311bbfbe82dcf/asm-util-3.2.jar, /Users/tnaleid/.gradle/caches/artifacts-8/filestore/asm/asm-analysis/3.2/jar/c624956db93975b7197699dcd7de6145ca7cf2c8/asm-analysis-3.2.jar] :compileJava UP-TO-DATE :compileGroovy UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar BUILD SUCCESSFUL Total time: 3.387 secs % jar tvf build/libs/gradletest.jar 0 Mon Mar 12 11:40:00 CDT 2012 META-INF/ 25 Mon Mar 12 11:40:00 CDT 2012 META-INF/MANIFEST.MF 0 Mon Mar 12 11:40:00 CDT 2012 lib/ 5546084 Mon Mar 05 13:13:32 CST 2012 lib/groovy-1.8.6.jar 445288 Mon Mar 05 13:13:38 CST 2012 lib/antlr-2.7.7.jar 43398 Mon Mar 05 13:13:40 CST 2012 lib/asm-3.2.jar 21878 Mon Mar 05 13:13:40 CST 2012 lib/asm-tree-3.2.jar 33094 Mon Mar 05 13:13:40 CST 2012 lib/asm-commons-3.2.jar 36551 Mon Mar 05 13:13:40 CST 2012 lib/asm-util-3.2.jar 17985 Mon Mar 05 13:13:40 CST 2012 lib/asm-analysis-3.2.jar
Ted Naleid Mar 12 2018-12-12T00: 00Z
source share