How to download dependency sources?

Many of my dependencies have a “sources” jar available alongside the binary jar. A binary jar named “foo-1.0.0.jar” may have a source jar named “foo-1.0.0-sources.jar” alongside it (no guarantee, though).

Somehow, the IDE tasks seem to be able to download these whenever they exist. I need to download these manually (for instance, in a Copy task). What’s the easiest/best way to do this?

In the future we want to provide an easy way to accomplish this, but for now you’d probably have to copy the code used by the IDE tasks.