How can I add an URL-based repository in a plugin so I can download a dependency from a SourceForge project?
I had something like this:
project.repositories.add(new CommonsHttpClientResolver(null, null)) {
name = 'SourceForge'
addArtifactPattern 'https://sourceforge.net/projects/[organization]/files/[organization]/[organization]-[revision]/[module]-[revision].[ext]/download'
}
But in 1.0-milestone-7 this internal CommonsHttpClientResolver class was removed. Its replacement, IvyResolver, is not as easy to use, as it needs some setup which I don’t know how to do.
I also tried Ivy’s URLResolver, but it seems this does not handle redirects (HTTP 302) at all.
I am not quite sure if this pattern applies to all SourceForge projects but here’s one example for a JAR file that I was able to download. I adapted to the link provided on the download page where it says “direct link”.
The problem with using URLResolver directly is that you miss out on a lot of Gradle goodness. While caching should work in general, you no longer benefit from sha1 matching of artifacts. So you’ll need to re-download the artifacts whenever you run with “–refresh dependencies” (M8) and often when you upgrade Gradle. Also, changing artifacts will be re-downloaded every resolve. So I’d like to help find a solution that doesn’t involve using an ivy resolver directly.
I see, the issue is that sourceforge is not returning a 404 when you request an unknown artifact. If you use the same (mirror-specific) url quoted by Benjamin Muschko above, it works.
Soon we are planning to add the ability to configure the meta-data format you want for a repository: maven, ivy, jarfile. This will help clarify the behaviour and should provide a way to get the regular sourceforge “*/download” url working.
Any idea when? I just decided to move our build from Maven to Gradle, predicated on the ability to create an uber jar (with Stig’s plugin). I’ll try your work around, but just curious as to when the ability you mention will be in place…