为gradlevfs插件配置代理



tl;dr:

如何配置gradle vfs插件使用的https代理?它似乎忽略了普通的java/gradle代理配置。

完整详细信息

基于这个gradle文件,我尝试使用gradle从asciidocs创建reveal.js幻灯片。

我已经使用grade.properties文件配置了代理设置,其内容类似于:

systemProp.http.proxyHost=myproxy
systemProp.http.proxyPort=8080
systemProp.http.nonProxyHosts=localhost
systemProp.https.proxyHost=myproxy
systemProp.https.proxyPort=8080
systemProp.https.nonProxyHosts=localhost

虽然这种配置适用于gradle,但在执行java构建(它下载插件和依赖项)时,参考构建文件中使用的vfs会失败:

:download FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'D:workspacesmyprojectbuild.gradle' line: 47
* What went wrong:
Execution failed for task ':download'.
> Could not connect to HTTP server on "github.com".

第47行是此块中第一个以cp开头的行:

task download << {
    mkdir downloadDir
    vfs {
         cp "zip:https://github.com/asciidoctor/asciidoctor-reveal.js/archive/${asciidoctorBackendVersion}.zip!asciidoctor-reveal.js-${asciidoctorBackendVersion}",
            templateDir, recursive:true, overwrite:true
        cp "zip:https://github.com/hakimel/reveal.js/archive/${revealjsVersion}.zip!reveal.js-${revealjsVersion}",
            revealjsDir, recursive:true, overwrite:true
    }
}

一个(我的)解决方案是添加定义Proxy参数的vfs选项。这可能更复杂,例如通过构建一个从系统环境中导出参数的任务,但这一个有效:

task download << {
    mkdir downloadDir
    vfs {
        options 'vfs.http.proxyHost' : 'mylocalsquid.lokal'
        options 'vfs.http.proxyPort' : '3128'
        options 'vfs.https.proxyHost' : 'mylocalsquid.lokal'
        options 'vfs.https.proxyPort' : '3128'
        cp "zip:https://github.com/asciidoctor/asciidoctor-reveal.js/archive/${asciidoctorBackendVersion}.zip!asciidoctor-reveal.js-${asciidoctorBackendVersion}",
            templateDir, recursive:true, overwrite:true
        cp "zip:https://github.com/hakimel/reveal.js/archive/${revealjsVersion}.zip!reveal.js-${revealjsVersion}",
            revealjsDir, recursive:true, overwrite:true
    }
}

这源于http://ysb33r.github.io/groovy-vfs/1.0/docs/product-documentation.html

相关内容

  • 没有找到相关文章

最新更新