How to copy external dependencies from maven into the distribution

We just switched to Gradle 1.9 and are now using maven to retrieve our external dependencies like so:

repositories {

mavenCentral() }

dependencies {

compile ‘org.slf4j:slf4j-api:1.7.2’ }

My question is how to get maven dependencies into our distribution when they’re needed for runtime. Previously we were doing something like this: task dist(type: Tar) {

dependsOn jar, javadoc, benchmarkJar, exampleJar

archiveName = jar.baseName + ‘-’ + jar.version + ‘.tgz’

compression = Compression.GZIP

into (‘lib’) {

from ‘build/distributions/’ + jar.archiveName

from ‘build/libs/slf4j-api-1.7.2.jar’ }

but now that we no longer have these files stored in lib, I don’t know how to copy them to the distribution.

Thanks, Brian

Simpler than you think:

from configurations.compile

Ah. NIce!

However I’m still not getting the dependencies from other sourcesets.

For example, we have this: sourceSets {

benchmark {

java {

srcDir ‘src/benchmark/java’

}

} }

dependencies {

benchmarkCompile sourceSets.main.output

benchmarkCompile files(‘lib/guava-11.0.2.jar’) }

I’ve tried adding either: from configurations.benchmarkCompile or from configurations.benchmarkRuntime

and in either case I’m getting a whole bunch of classes that I don’t want (likely due to the sourceSets.main.output dependency).

Any way to just get the jar dependencies?

Thanks! Brian

I have a somewhat related question:

How do I get gradle to just copy the compiled jar, together with all of its dependencies and transitive dependencies, to an arbitrary directory, without zipping it up?

Guess this is bone simple:

task flatDist(dependsOn: ‘build’, type: Copy) {

from configurations.runtime

from ‘build/libs’

into ‘build/dist’ }

For mine, I ended up doing:

from configurations.benchmarkRuntime { exclude ‘com**’ }

that seems to work.

Where is benchmarkRuntime defined?