First solution
Don't leave Gradle. Instead, try use a file collection. It should work! But not for me, se second solution
dependencies {
def webHostedJarFiles = ["http://url.to.jar", "http://url.to.second.jar"]
.collect{fileName->new File(fileName)}
compile([
files{webHostedJarFiles},
'commons-validator:commons-validator:1.4.1'
/* and all the other Maven dependencies...*/])
}
Putting the URLs directly in the files method gives you a Cannot convert URL "http://url.to.jar" to a file exception
By some reason this did not work for me. The dependencies were downloaded and showed up in the gradle plugin of IntelliJ, but when compiling the comilpiler seemed not to be able to find the.
Second solution
Don't leave Gradle. Instead download the files into a libs folder.
Copy task:
task downloadJarsToLibs(){
def f = new File('libs/myFile.jar')
if (!f.exists()) {
new URL('http://path.to/myFile.jar').withInputStream{ i -> f.withOutputStream{ it << i }}
}
}
Dependencies:
dependencies {
compile([
fileTree(dir: 'libs', include: ['*.jar']),
'commons-validator:commons-validator:1.4.1'
/* and all the other Maven dependencies...*/])
}
Third Solution (Cortesey of @RaGe)
Example files:
http://exampe.com/uda/virtuoso/7.2/rdfproviders/jena/210/virt_jena2.jar
http://exampe.com/uda/virtuoso/7.2/jdbc/virtjdbc4.jar
build.gradle:
repositories {
ivy {
url 'http://example.com/'
layout 'pattern', {
artifact '/uda/[organisation]/7.2/[module]/[revision].[ext]'
}
// This is required in Gradle 6.0+ as metadata file (ivy.xml)
// is mandatory. Docs linked below this code section
metadataSources { artifact() }
}
mavenCentral()
}
dependencies {
compile 'virtuoso:rdfproviders/jena210:virt_jena2:jar', 'virtuoso:jdbc:virtjdbc4:jar'
}
reference for required metadata here
Unfortunately this does not seem to work for my setup, but Gradle is happy and files are downloaded when needed (since they are cached)