How can I download a dependency from an arbitrary URL?


(nolan) #1

I need a jar in one of my projects that is only available from a Google Code URL.

I’ve seen this:

http://gradle.1045684.n5.nabble.com/Dependency-from-an-arbitrary-URL-td1433384.html

And tried:

dependencies {

compile “org.mozilla:rhino:1.7R2” {

artifact {

name = “rhino”

extension = “jar”

type = “jar”

url = “http://android-scripting.googlecode.com/hg/rhino/rhino1_7R2.jar

}

} }

And I get:

Could not find method org.mozilla:rhino:1.7R2() for arguments [build_1gh5ah50c852d3t8io63o8jnoc$_run_closure2_closure6@39fa487f] on root project ‘working’.

What am I missing?

Thanks.


(Peter Niederwieser) #2

That syntax is for uploading artifacts, not for downloading them. Gradle’s dependency management doesn’t currently offer a way to download from an arbitrary URL. You could try to pretend that it’s an Ivy repo with custom artifact pattern. Or, if you don’t need the caching and such, just use the usual Java/Groovy means to download from an URL.

Other solutions are to store the artifact in your company/project repository, or to commit it to source control. Recent versions of Rhino are also available from Maven Central.


(Peter Niederwieser) #3

Actually, according to the thread you linked to there is such a syntax. Not sure if it’s an official feature though and whether it still works. Have never heard about if before.


(Peter Niederwieser) #4

The thing that you are missing in your code is parens around ‘“org.mozilla:rhino:1.7R2”’.


(Peter Niederwieser) #5

Officially, Gradle’s dependency management doesn’t currently offer a way to download from an arbitrary URL. You could try to pretend that it’s an Ivy repo with custom artifact pattern. Or, if you don’t need the caching and such, just use the usual Java/Groovy means to download from an URL.

Other solutions are to store the artifact in your company/project repository, or to commit it to source control. Recent versions of Rhino are also available from Maven Central.

That said, the hack mentioned in the thread that you linked to might still work. What you are missing in your code is parens around ‘“org.mozilla:rhino:1.7R2”’.