0

Assuming my gradle dependencies are :

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile 'org.apache.commons:commons-io:1.3.2'
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

How can I add them in a jar file which is being created with java plugin and :jar task?

I only found this solution for the libs but didn't work either.

See that I have both local dependencies and maven dependencies.

Diolor
  • 13,181
  • 30
  • 111
  • 179

1 Answers1

1
jar {
    from { configurations.runtime.collect { zipTree(it) } }
}
Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • I can see the jars inside but they cannot be read (`NoClassDefFoundError`). Probably something wrong with my classpath, I investigate – Diolor Sep 14 '14 at 18:49
  • 1
    the problem is probably, that you need the unzipped jars in the jar. have a look at this stov thread: http://stackoverflow.com/questions/10986244/building-a-uberjar-with-gradle – Rene Groeschke Sep 14 '14 at 19:34