Plain URL dependencies

What’s the best way to have a Gradle build depend on a file downloaded from a plain http URL? This is a file that isn’t part of an Ivy/Maven repository, though it does have a version number in its path and can be cached.

(I’ve tried using as well as invoking the ant get task, but neither of those caches the downloaded file across builds.)

I think what you need to do is specify this URL as a repository and specify a normal dependency. I haven’t done this, but from what I just read, it seems like if you specify this as a “maven” repository, even though it doesn’t have a POM descriptor, it should find the jar.

I found an old thread that seems to be relevant.

I would go with a ivy repository and a custom url pattern you need to
configure. have a look at the according chapter in the gradle userguide

Thanks for your advice, @Rene and @David_Karr! I was able to add an Ivy repository containing my dependency.

For those that will later stumble across this :

  • here is a good answer that explains how to define the pattern of the ivy repository
  • the gradle-download-task plugin works well, and you can manually add the caching mechanism by copy-pasting that code. Most probably, soon it will include the caching mechanism by default