Gradle non-managed remote dependency

2019-09-09 22:24发布

问题:

I have a jar dependency that resides on a remote server. How do I resolve that in Gradle? There doesn't seem to be a way to define a repository for remote files, only local files, and I'm something like this doesn't seem to work either:

compile("group:name:version") {
  artifact {
    url = "http://server/dep.jar"
  }
}

The docs seems to hint that something like this should be possible, but so far I'm unable to find an example anywhere.

Support for non-managed dependencies: If your dependencies are simply files in version control or a shared drive, Gradle provides powerful functionality to support this.

Any ideas?

回答1:

Unfortunately, according to gradle documentation a remote share is currently not supported. However, this can be worked-around easily by doing the following:

  1. Copy that will copy the remote jars locally. A possible location for such code can be the repositories configuration to ensure that the files will be copied before the dependencies will get resolved.
  2. Define a local repository pointing to the local location of jars.