Dean Hiller
Dean Hiller

Reputation: 20190

how to copy all source jars in the dependencies section to a directory in gradle

I can copy all the jars in dependency section for "compile" configuration like so

task('copyJars') { 
    ext.collection = files { genLibDir.listFiles() }
    delete ext.collection
    copy { from configurations.compile into genLibDir }
}

but how do I copy their source jar files somewhere?

thanks, Dean

Upvotes: 1

Views: 762

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123910

As of Gradle 1.0, I don't know of an easy way to deal with third-party sources Jars. You could add them as explicit dependencies (to a separate configuration) or maybe crawl the Gradle cache.

By the way, delete ext.collection is in the wrong spot. It will be executed in the configuration phase, and will delete files no matter which tasks are going to be executed. (Also listFiles() will get invoked for every build.)

Also, a task whose main purpose is copying should alway use the Copy task type rather than the copy method.

Upvotes: 1

Related Questions