如何从代理后面使用 sbt? [英] How to use sbt from behind proxy?

查看:36
本文介绍了如何从代理后面使用 sbt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置 sbt 以使用代理?

How do I configure sbt to use a proxy?

例如,我的构建定义需要连接到GitHub,为http.proxyhttp.proxyPortuser指定连接参数,和密码.

For example, my build definition needs to connect to GitHub, specifying connection parameters for http.proxy, http.proxyPort, user, and password.

我如何将这些设置传递给 sbt?

How would I pass in these settings to sbt?

当我在家工作时,是否有一种简单的方法可以在代理/无代理设置之间切换?

Is there an easy way to switch between proxy/no-proxy settings for when I work from home?

推荐答案

sbt 尊重 http 代理设置的常用环境变量:

sbt respects the usual environment variables for http proxy settings:

export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=yourserver -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password"

(当然,假设是 Unix(Linux/OSX 等).在 Windows 上,您可以像往常一样以 Windows 方式设置相同的环境变量 (%JAVA_OPTS%).)

然后像往常一样运行sbt:

sbt

在代理/无代理之间切换应该是设置一个小脚本的问题,您可以在需要时啜饮"它.

Switching between proxy/no-proxy should be a matter of setting up a little script that you can 'slurp' in whenever you need it.

  • 不要在 yourserver 值中包含http://"
  • 不要在 yourserver 值中包含端口
  • 您可能还想包括 https.proxyHosthttps.proxyPort,因为很多东西都通过 https 工作
  • 如果您的代理需要身份验证,请不要尝试,除非它仅使用基本身份验证,因为 SBT 不支持其他任何内容.还要始终注意将凭据明文发送到环境变量中!请务必使用不会创建跟踪文件的文本编辑方法从 .bash_history 中删除命令(从技术上讲,您应该 shr​​edsrm 整个文件).如果您使用的是 Windows,请不要担心,您的安全已经搞砸了,您不能再造成任何伤害了.
  • Don't include "http://" in the yourserver value
  • Don't include the port in the yourserver value
  • You probably also want to include https.proxyHost and https.proxyPort since a lot of stuff works over https
  • If your proxy requires authentication, don't even bother trying unless it just uses Basic Authentication as SBT doesn't support anything else. Also always beware clear texting credentials into environment variables! Be sure to remove the commands from your .bash_history using a text editing method that won't create trace files (technically you should shred or srm the entire file). If you are on Windows, don't worry about it, your security is already messed up you can't do any more harm.

这篇关于如何从代理后面使用 sbt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆