从特定URL获取依赖项

时间:2015-05-04 18:53:41

标签: gradle

如何从特定网址获取依赖关系,即我想做类似的事情:

dependencies {
    compile 'http://rforge.net/Rserve/files/RserveEngine.jar'
    compile 'http://rforge.net/Rserve/files/REngine.jar'
}

这是可能的,还是我必须在单独的任务中下载jar并使用

添加它们
compile files('....')

1 个答案:

答案 0 :(得分:2)

Basically this is the way to go:

apply plugin: 'java'

repositories {
    ivy {
        url 'http://rforge.net/Rserve/files/'
        layout "pattern", {
            artifact "[artifact].[ext]"
        }
    }
}

configurations{
    rserve
}

dependencies {
    rserve name: 'RserveEngine'
    rserve name: 'REngine'
}

task fetchRserve(type: Copy) {
    from configurations.rserve
    into "$buildDir/rserve"
}

You can experiment with ivy layout to introduce modules, versions, extensions. Here the docs can be found.