如何在代理后使用sbt ?

时间:2022-08-25 22:09:48

How do I configure sbt to use a proxy?

如何配置sbt来使用代理?

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

例如,我的构建定义需要连接到GitHub,为http指定连接参数。代理,http。proxyPort、用户和密码。

How would I pass in these settings to sbt?

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

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

在我在家工作的时候,有没有一种简单的方式来切换代理/无代理设置?

13 个解决方案

#1


115  

sbt respects the usual environment variables for http proxy settings:

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

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

(That's of course, assuming Unix (Linux/OSX etc). On windows you could just set the same environment variable (%JAVA_OPTS%) as usual in the Windows way.)

当然,前提是Unix (Linux/OSX等)。在windows上,您可以按照windows的方式设置相同的环境变量(%JAVA_OPTS%)。

Then run sbt as usual:

然后像往常一样运行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.

在代理/无代理之间切换应该是设置一个小脚本,您可以在需要的时候使用它。

Gotchas

  • Don't include "http://" in the yourserver value
  • 不要在您的服务器值中包含“http://”
  • 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
  • 您可能还希望包含https。proxyHost和https。proxyPort因为很多东西都在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不支持其他任何东西。还要注意,在环境变量中要清楚地输入短信凭证!请确保使用不会创建跟踪文件的文本编辑方法从.bash_history中删除命令(从技术上来说,应该对整个文件进行剪切或srm)。如果你在Windows操作系统上,别担心,你的安全已经一团糟了,你不能再做任何坏事了。

#2


22  

sbt works in a fairly standard way comparing to the way other JVM-based projects are usually configured.

与其他基于jvm的项目通常配置的方式相比,sbt以相当标准的方式工作。

sbt is in fact two "subsystems" - the launcher and the core. It's usually xsbt.boot.Boot that gets executed before the core starts up with the features we all know (and some even like).

sbt实际上是两个“子系统”——启动器和核心。通常xsbt.boot。在核心开始使用我们都知道的特性(有些甚至像这样)之前执行的引导。

It's therefore a matter of how you execute sbt that says how you could set up a proxy for HTTP, HTTPS and FTP network traffic.

因此,问题在于如何执行sbt,如何为HTTP、HTTPS和FTP网络流量设置代理。

The following is the entire list of the available properties that can be set for any Java application, sbt including, that instruct the Java API to route communication through a proxy:

下面是可以为任何Java应用程序设置的所有可用属性的完整列表,其中包括指示Java API通过代理路由通信的属性:

  • http_proxy
  • http_proxy
  • http_proxy_user
  • http_proxy_user
  • http_proxy_pass
  • http_proxy_pass
  • http.proxyHost
  • http.proxyHost
  • http.proxyPort
  • http.proxyPort
  • http.proxyUser
  • http.proxyUser
  • http.proxyPassword
  • http.proxyPassword

Replace http above with https and ftp to get the list of the properties for the services.

使用https和ftp替换上面的http,以获取服务的属性列表。

Some sbt scripts use JAVA_OPTS to set up the proxy settings with -Dhttp.proxyHost and -Dhttp.proxyPort amongst the others (listed above). See Java Networking and Proxies.

一些sbt脚本使用JAVA_OPTS使用-Dhttp设置代理。proxyHost -Dhttp。proxyPort和其他(上面列出的)。请参阅Java网络和代理。

Some scripts come with their own way of setting up proxy configuration using the SBT_OPTS property, .sbtopts or (only on Windows) %SBT_HOME%\conf\sbtconfig.txt. You can use them to specifically set sbt to use proxies while the other JVM-based applications are not affected at all.

有些脚本使用SBT_OPTS属性、.sbtopts或(仅在Windows上)%SBT_HOME%\conf\sbtconfig.txt设置代理配置。您可以使用它们专门设置sbt来使用代理,而其他基于jvm的应用程序则完全不受影响。

From the sbt command line tool:

来自sbt命令行工具:

# jvm options and output control
JAVA_OPTS          environment variable, if unset uses "$java_opts"
SBT_OPTS           environment variable, if unset uses "$default_sbt_opts"
.sbtopts           if this file exists in the current directory, it is
                   prepended to the runner args
/etc/sbt/sbtopts   if this file exists, it is prepended to the runner args
-Dkey=val          pass -Dkey=val directly to the java runtime
-J-X               pass option -X directly to the java runtime 
                   (-J is stripped)
-S-X               add -X to sbt's scalacOptions (-S is stripped)

And here comes an excerpt from sbt.bat:

以下是来自sbt.bat的一段摘录:

@REM Envioronment:
@REM JAVA_HOME - location of a JDK home dir (mandatory)
@REM SBT_OPTS  - JVM options (optional)
@REM Configuration:
@REM sbtconfig.txt found in the SBT_HOME.

Be careful with sbtconfig.txt that just works on Windows only. When you use cygwin the file is not consulted and you will have to resort to using the other approaches.

小心sbtconfig。txt,只适用于Windows。当您使用cygwin时,不会参考该文件,您将不得不使用其他方法。

I'm using sbt with the following script:

我使用sbt的脚本如下:

$JAVA_HOME/bin/java $SBT_OPTS -jar /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar "$@"

The point of the script is to use the latest version of sbt built from the sources (that's why I'm using /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar) with $SBT_OPTS property as a means of passing JVM properties to the JVM sbt uses.

该脚本的重点是使用从源代码构建的sbt的最新版本(这就是为什么我使用/ user /jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jar /sbt-launch.jar),以$SBT_OPTS属性作为将JVM属性传递给JVM sbt使用的一种方法。

The script above lets me to set proxy on command line on MacOS X as follows:

上面的脚本让我可以在MacOS X的命令行上设置proxy,如下所示:

SBT_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=9999" sbt

As you can see, there are many approaches to set proxy for sbt that all pretty much boil down to set a proxy for the JVM sbt uses.

如您所见,有许多方法可以为sbt设置代理,这些方法可以归结为为为JVM sbt使用的代理设置代理。

#3


9  

I used (this is a unix environment) :

我使用(这是一个unix环境):

export SBT_OPTS="$SBT_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"

This did not work for my setup :

这对我的设置不起作用:

export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"

In sbt.sh file :

在sbt。sh文件:

JAVA_OPTS          environment variable, if unset uses "$java_opts"
SBT_OPTS           environment variable, if unset uses "$default_sbt_opts"

But apparently SBT_OPTS is used instead of JAVA_OPTS

但显然,SBT_OPTS是用来代替JAVA_OPTS的。

#4


9  

In windows environment simply add following line in the sbt/sbtconfig.txt

在windows环境中,只需在sbt/sbtconfig.txt中添加以下一行即可

-Dhttp.proxyHost=PROXYHOST 
-Dhttp.proxyPort=PROXYPORT 
-Dhttp.proxyUser=USERNAME 
-Dhttp.proxyPassword=XXXX

or the Https equivalent (thanks to comments)

或者是Https(感谢评论)

-Dhttps.proxyHost=PROXYHOST 
-Dhttps.proxyPort=PROXYPORT 
-Dhttps.proxyUser=USERNAME 
-Dhttps.proxyPassword=XXXX

#5


8  

For Windows users, enter the following command :

对于Windows用户,输入以下命令:

set JAVA_OPTS=-Dhttp.proxySet=true -Dhttp.proxyHost=[Your Proxy server] -Dhttp.proxyPort=8080

#6


5  

To provide one answer that will work for all Windows-users:

提供一个适用于所有windows用户的答案:

Add the following to your sbtconfig.txt (C:\Program Files (x86)\sbt\conf)

向您的sbtconfig添加以下内容。txt(C:\程序文件(x86)\ sbt \ conf)

-Dhttp.proxyHost=XXXXXXX -Dhttp.proxyPort=YYYY -Dhttp.proxySet=true -Dhttps.proxyHost=XXXXXXX -Dhttps.proxyPort=YYYY -Dhttps.proxySet=true

Replace both XXXXXXX with your proxyHost, and both YYYY with your proxyPort.

用proxyHost替换xxxxx,用proxyPort替换yyyyyyy。

If you get the error "Could not find or load main class" you need to set your JAVA_HOME:

如果您收到“无法找到或加载主类”错误,则需要设置JAVA_HOME:

set JAVA_HOME=C:\Progra~1\Java\jdkxxxxxx

When on 64-bit windows, use:

在64位windows上,使用:

Progra~1 = 'Program Files'

Progra ~ 1 =“程序文件”

Progra~2 = 'Program Files(x86)'

Progra ~ 2 =“程序文件(x86)”

#7


4  

Add both http and https configuration:

添加http和https配置:

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

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

(https config is must, since many urls referred by the sbt libraries are https)

(必须使用https配置,因为sbt库引用的许多url都是https)

In fact, I even had an extra setting 'http.proxySet' to 'true' in both configuration entries.

事实上,我甚至还有一个额外的设置“http”。在两个配置项中proxySet' to 'true'。

#8


3  

When I added the proxy info to the %JAVA_OPTS%, I got an error "-Dhttp.proxyHost=yourserver was unexpected at this time". I put the proxy info in %SBT_OPTS% and it worked.

当我将代理信息添加到%JAVA_OPTS%时,我得到了一个错误”-Dhttp。此时,proxyHost=您的服务器是意想不到的。我将代理信息放在%SBT_OPTS%中,它就工作了。

#9


2  

I found an item on the FAQ section of Lightbend Activator useful. I am using Activator, which in turn uses SBT, so not sure if this helps users with just SBT, but if you use Activator, like me, and are behind a proxy, follow the instructions in the "Behind A Proxy" section of the FAQ:

我在Lightbend Activator的FAQ部分找到了一个有用的项目。我使用的是Activator,而Activator又使用了SBT,所以我不确定这是否能帮助用户使用SBT,但是如果你像我一样使用Activator,并且使用了一个代理,请按照FAQ“代理”部分“代理”中的说明:

https://www.lightbend.com/activator/docs

https://www.lightbend.com/activator/docs

Just in case the content disappears, here's a copy-paste:

以防内容消失,这里有一个复制粘贴:

When running activator behind a proxy, some additional configuration is needed. First, open the activator configuration file, found in your user home directory under ~/.activator/activatorconfig.txt. Note that this file may not exist. Add the following lines (one option per line):

当在代理后面运行activator时,需要一些额外的配置。首先,打开激活器配置文件,在~/.activator/activatorconfig.txt下的用户主目录中找到。注意,该文件可能不存在。添加以下行(每行一个选项):

-Dhttp.proxyHost=PUT YOUR PROXY HOST HERE
-Dhttp.proxyPort=PUT YOUR PROXY PORT HERE
-Dhttp.nonProxyHosts="localhost|127.0.0.1"
-Dhttps.proxyHost=PUT YOUR HTTPS PROXY HOST HERE
-Dhttps.proxyPort=PUT YOUR HTTPS PROXY PORT HERE
-Dhttps.nonProxyHosts="localhost|127.0.0.1"

#10


2  

SBT use both HTTP/HTTPS/SFTP/SSH and other kind of connections to a repository. so when behind a proxy, these protocols should be available.

SBT使用HTTP/HTTPS/SFTP/SSH和其他类型的连接到存储库。因此,在代理之后,这些协议应该是可用的。

In most simple cases on Windows, you just need to pass proxy parameters options to JVM, like:

在Windows的大多数简单案例中,您只需要将代理参数选项传递给JVM,比如:

java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080

That will do.

这将做的。

But if not, there are few things you should be aware of:

但如果没有,你应该注意的事情很少:

  1. whether if you are making a HTTPS connection to the repository.
  2. 是否正在建立到存储库的HTTPS连接。
  3. whether sever certificates been imported to jre cacerts
  4. 是否将服务器证书导入jre cacerts
  5. whether your proxy would replace your server certificates
  6. 您的代理是否会替换服务器证书

to solve first, you should pass https proxy parameter to jvm, like:

要解决第一个问题,您应该将https代理参数传递给jvm,比如:

java -Dhttps.proxyHost=myproxy -Dhttps.proxyPort=8080 -Djavax.net.ssl.trustStore=${TRUST_STORE_PATH}

to solve the second, you should import the ca. there are a lot of tips.

要解决第二个问题,您应该导入ca。

to solve the third, you maybe could considering using a authentication proxy.

要解决第三个问题,您可以考虑使用身份验证代理。

to Simplify the config of SBT, it provide sbtconfig.txt and sbtops in the conf directory, look into it.

为了简化SBT的配置,它提供了sbtconfig。在conf目录中的txt和sbtops,查看它。

Reference:
http://www.scala-sbt.org/0.13/docs/Setup-Notes.html
http://www.scala-sbt.org/1.0/docs/Publishing.html

参考:http://www.scala-sbt.org/0.13/docs/Setup-Notes.html http://www.scala-sbt.org/1.0/docs/Publishing.html

#11


1  

Using

使用

sbt -Dhttp.proxyHost=yourServer-Dhttps.proxyHost=yourServer -Dhttp.proxyPort=yourPort -Dhttps.proxyPort=yourPort

works in Ubuntu 15.10 x86_64 x86_64 GNU/Linux.

适用于Ubuntu 15.10 x86_64 x86_64 GNU/Linux。

Replace yourServer by the proper address without the http:// nor https:// prefixes in Dhttp and Dhttps, respectively. Remember to avoid the quotation marks. No usr/pass included in the code-line, to include that just add -Dhttp.proxyUser=usr -Dhttp.proxyPassword=pass with the same typing criteria. Thanks @Jacek Laskowski!. Cheers

用正确的地址替换您的服务器,不使用Dhttp和Dhttps中的http://或https://前缀。记住要避免使用引号。代码行中不包含usr/pass,只需添加-Dhttp即可。proxyUser = usr -Dhttp。proxyPassword=以相同的类型通过。拉斯科夫斯基@Jacek !谢谢你。干杯

#12


1  

I found that starting IntelliJ IDEA from terminal let me connect and download over the internet. To start from terminal, type in:

我发现从终端开始的IntelliJ IDEA可以让我通过互联网连接和下载。从终端开始,输入:

$ idea

美元的想法

#13


0  

On Mac OS X / El Capitan you can set java environment variables:

在Mac OS X / El Capitan上可以设置java环境变量:

$launchctl setenv _JAVA_OPTIONS "-Dhttp.proxyHost=192.168.1.54 -Dhttp.proxyPort=9999"

#1


115  

sbt respects the usual environment variables for http proxy settings:

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

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

(That's of course, assuming Unix (Linux/OSX etc). On windows you could just set the same environment variable (%JAVA_OPTS%) as usual in the Windows way.)

当然,前提是Unix (Linux/OSX等)。在windows上,您可以按照windows的方式设置相同的环境变量(%JAVA_OPTS%)。

Then run sbt as usual:

然后像往常一样运行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.

在代理/无代理之间切换应该是设置一个小脚本,您可以在需要的时候使用它。

Gotchas

  • Don't include "http://" in the yourserver value
  • 不要在您的服务器值中包含“http://”
  • 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
  • 您可能还希望包含https。proxyHost和https。proxyPort因为很多东西都在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不支持其他任何东西。还要注意,在环境变量中要清楚地输入短信凭证!请确保使用不会创建跟踪文件的文本编辑方法从.bash_history中删除命令(从技术上来说,应该对整个文件进行剪切或srm)。如果你在Windows操作系统上,别担心,你的安全已经一团糟了,你不能再做任何坏事了。

#2


22  

sbt works in a fairly standard way comparing to the way other JVM-based projects are usually configured.

与其他基于jvm的项目通常配置的方式相比,sbt以相当标准的方式工作。

sbt is in fact two "subsystems" - the launcher and the core. It's usually xsbt.boot.Boot that gets executed before the core starts up with the features we all know (and some even like).

sbt实际上是两个“子系统”——启动器和核心。通常xsbt.boot。在核心开始使用我们都知道的特性(有些甚至像这样)之前执行的引导。

It's therefore a matter of how you execute sbt that says how you could set up a proxy for HTTP, HTTPS and FTP network traffic.

因此,问题在于如何执行sbt,如何为HTTP、HTTPS和FTP网络流量设置代理。

The following is the entire list of the available properties that can be set for any Java application, sbt including, that instruct the Java API to route communication through a proxy:

下面是可以为任何Java应用程序设置的所有可用属性的完整列表,其中包括指示Java API通过代理路由通信的属性:

  • http_proxy
  • http_proxy
  • http_proxy_user
  • http_proxy_user
  • http_proxy_pass
  • http_proxy_pass
  • http.proxyHost
  • http.proxyHost
  • http.proxyPort
  • http.proxyPort
  • http.proxyUser
  • http.proxyUser
  • http.proxyPassword
  • http.proxyPassword

Replace http above with https and ftp to get the list of the properties for the services.

使用https和ftp替换上面的http,以获取服务的属性列表。

Some sbt scripts use JAVA_OPTS to set up the proxy settings with -Dhttp.proxyHost and -Dhttp.proxyPort amongst the others (listed above). See Java Networking and Proxies.

一些sbt脚本使用JAVA_OPTS使用-Dhttp设置代理。proxyHost -Dhttp。proxyPort和其他(上面列出的)。请参阅Java网络和代理。

Some scripts come with their own way of setting up proxy configuration using the SBT_OPTS property, .sbtopts or (only on Windows) %SBT_HOME%\conf\sbtconfig.txt. You can use them to specifically set sbt to use proxies while the other JVM-based applications are not affected at all.

有些脚本使用SBT_OPTS属性、.sbtopts或(仅在Windows上)%SBT_HOME%\conf\sbtconfig.txt设置代理配置。您可以使用它们专门设置sbt来使用代理,而其他基于jvm的应用程序则完全不受影响。

From the sbt command line tool:

来自sbt命令行工具:

# jvm options and output control
JAVA_OPTS          environment variable, if unset uses "$java_opts"
SBT_OPTS           environment variable, if unset uses "$default_sbt_opts"
.sbtopts           if this file exists in the current directory, it is
                   prepended to the runner args
/etc/sbt/sbtopts   if this file exists, it is prepended to the runner args
-Dkey=val          pass -Dkey=val directly to the java runtime
-J-X               pass option -X directly to the java runtime 
                   (-J is stripped)
-S-X               add -X to sbt's scalacOptions (-S is stripped)

And here comes an excerpt from sbt.bat:

以下是来自sbt.bat的一段摘录:

@REM Envioronment:
@REM JAVA_HOME - location of a JDK home dir (mandatory)
@REM SBT_OPTS  - JVM options (optional)
@REM Configuration:
@REM sbtconfig.txt found in the SBT_HOME.

Be careful with sbtconfig.txt that just works on Windows only. When you use cygwin the file is not consulted and you will have to resort to using the other approaches.

小心sbtconfig。txt,只适用于Windows。当您使用cygwin时,不会参考该文件,您将不得不使用其他方法。

I'm using sbt with the following script:

我使用sbt的脚本如下:

$JAVA_HOME/bin/java $SBT_OPTS -jar /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar "$@"

The point of the script is to use the latest version of sbt built from the sources (that's why I'm using /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar) with $SBT_OPTS property as a means of passing JVM properties to the JVM sbt uses.

该脚本的重点是使用从源代码构建的sbt的最新版本(这就是为什么我使用/ user /jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jar /sbt-launch.jar),以$SBT_OPTS属性作为将JVM属性传递给JVM sbt使用的一种方法。

The script above lets me to set proxy on command line on MacOS X as follows:

上面的脚本让我可以在MacOS X的命令行上设置proxy,如下所示:

SBT_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=9999" sbt

As you can see, there are many approaches to set proxy for sbt that all pretty much boil down to set a proxy for the JVM sbt uses.

如您所见,有许多方法可以为sbt设置代理,这些方法可以归结为为为JVM sbt使用的代理设置代理。

#3


9  

I used (this is a unix environment) :

我使用(这是一个unix环境):

export SBT_OPTS="$SBT_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"

This did not work for my setup :

这对我的设置不起作用:

export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"

In sbt.sh file :

在sbt。sh文件:

JAVA_OPTS          environment variable, if unset uses "$java_opts"
SBT_OPTS           environment variable, if unset uses "$default_sbt_opts"

But apparently SBT_OPTS is used instead of JAVA_OPTS

但显然,SBT_OPTS是用来代替JAVA_OPTS的。

#4


9  

In windows environment simply add following line in the sbt/sbtconfig.txt

在windows环境中,只需在sbt/sbtconfig.txt中添加以下一行即可

-Dhttp.proxyHost=PROXYHOST 
-Dhttp.proxyPort=PROXYPORT 
-Dhttp.proxyUser=USERNAME 
-Dhttp.proxyPassword=XXXX

or the Https equivalent (thanks to comments)

或者是Https(感谢评论)

-Dhttps.proxyHost=PROXYHOST 
-Dhttps.proxyPort=PROXYPORT 
-Dhttps.proxyUser=USERNAME 
-Dhttps.proxyPassword=XXXX

#5


8  

For Windows users, enter the following command :

对于Windows用户,输入以下命令:

set JAVA_OPTS=-Dhttp.proxySet=true -Dhttp.proxyHost=[Your Proxy server] -Dhttp.proxyPort=8080

#6


5  

To provide one answer that will work for all Windows-users:

提供一个适用于所有windows用户的答案:

Add the following to your sbtconfig.txt (C:\Program Files (x86)\sbt\conf)

向您的sbtconfig添加以下内容。txt(C:\程序文件(x86)\ sbt \ conf)

-Dhttp.proxyHost=XXXXXXX -Dhttp.proxyPort=YYYY -Dhttp.proxySet=true -Dhttps.proxyHost=XXXXXXX -Dhttps.proxyPort=YYYY -Dhttps.proxySet=true

Replace both XXXXXXX with your proxyHost, and both YYYY with your proxyPort.

用proxyHost替换xxxxx,用proxyPort替换yyyyyyy。

If you get the error "Could not find or load main class" you need to set your JAVA_HOME:

如果您收到“无法找到或加载主类”错误,则需要设置JAVA_HOME:

set JAVA_HOME=C:\Progra~1\Java\jdkxxxxxx

When on 64-bit windows, use:

在64位windows上,使用:

Progra~1 = 'Program Files'

Progra ~ 1 =“程序文件”

Progra~2 = 'Program Files(x86)'

Progra ~ 2 =“程序文件(x86)”

#7


4  

Add both http and https configuration:

添加http和https配置:

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

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

(https config is must, since many urls referred by the sbt libraries are https)

(必须使用https配置,因为sbt库引用的许多url都是https)

In fact, I even had an extra setting 'http.proxySet' to 'true' in both configuration entries.

事实上,我甚至还有一个额外的设置“http”。在两个配置项中proxySet' to 'true'。

#8


3  

When I added the proxy info to the %JAVA_OPTS%, I got an error "-Dhttp.proxyHost=yourserver was unexpected at this time". I put the proxy info in %SBT_OPTS% and it worked.

当我将代理信息添加到%JAVA_OPTS%时,我得到了一个错误”-Dhttp。此时,proxyHost=您的服务器是意想不到的。我将代理信息放在%SBT_OPTS%中,它就工作了。

#9


2  

I found an item on the FAQ section of Lightbend Activator useful. I am using Activator, which in turn uses SBT, so not sure if this helps users with just SBT, but if you use Activator, like me, and are behind a proxy, follow the instructions in the "Behind A Proxy" section of the FAQ:

我在Lightbend Activator的FAQ部分找到了一个有用的项目。我使用的是Activator,而Activator又使用了SBT,所以我不确定这是否能帮助用户使用SBT,但是如果你像我一样使用Activator,并且使用了一个代理,请按照FAQ“代理”部分“代理”中的说明:

https://www.lightbend.com/activator/docs

https://www.lightbend.com/activator/docs

Just in case the content disappears, here's a copy-paste:

以防内容消失,这里有一个复制粘贴:

When running activator behind a proxy, some additional configuration is needed. First, open the activator configuration file, found in your user home directory under ~/.activator/activatorconfig.txt. Note that this file may not exist. Add the following lines (one option per line):

当在代理后面运行activator时,需要一些额外的配置。首先,打开激活器配置文件,在~/.activator/activatorconfig.txt下的用户主目录中找到。注意,该文件可能不存在。添加以下行(每行一个选项):

-Dhttp.proxyHost=PUT YOUR PROXY HOST HERE
-Dhttp.proxyPort=PUT YOUR PROXY PORT HERE
-Dhttp.nonProxyHosts="localhost|127.0.0.1"
-Dhttps.proxyHost=PUT YOUR HTTPS PROXY HOST HERE
-Dhttps.proxyPort=PUT YOUR HTTPS PROXY PORT HERE
-Dhttps.nonProxyHosts="localhost|127.0.0.1"

#10


2  

SBT use both HTTP/HTTPS/SFTP/SSH and other kind of connections to a repository. so when behind a proxy, these protocols should be available.

SBT使用HTTP/HTTPS/SFTP/SSH和其他类型的连接到存储库。因此,在代理之后,这些协议应该是可用的。

In most simple cases on Windows, you just need to pass proxy parameters options to JVM, like:

在Windows的大多数简单案例中,您只需要将代理参数选项传递给JVM,比如:

java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080

That will do.

这将做的。

But if not, there are few things you should be aware of:

但如果没有,你应该注意的事情很少:

  1. whether if you are making a HTTPS connection to the repository.
  2. 是否正在建立到存储库的HTTPS连接。
  3. whether sever certificates been imported to jre cacerts
  4. 是否将服务器证书导入jre cacerts
  5. whether your proxy would replace your server certificates
  6. 您的代理是否会替换服务器证书

to solve first, you should pass https proxy parameter to jvm, like:

要解决第一个问题,您应该将https代理参数传递给jvm,比如:

java -Dhttps.proxyHost=myproxy -Dhttps.proxyPort=8080 -Djavax.net.ssl.trustStore=${TRUST_STORE_PATH}

to solve the second, you should import the ca. there are a lot of tips.

要解决第二个问题,您应该导入ca。

to solve the third, you maybe could considering using a authentication proxy.

要解决第三个问题,您可以考虑使用身份验证代理。

to Simplify the config of SBT, it provide sbtconfig.txt and sbtops in the conf directory, look into it.

为了简化SBT的配置,它提供了sbtconfig。在conf目录中的txt和sbtops,查看它。

Reference:
http://www.scala-sbt.org/0.13/docs/Setup-Notes.html
http://www.scala-sbt.org/1.0/docs/Publishing.html

参考:http://www.scala-sbt.org/0.13/docs/Setup-Notes.html http://www.scala-sbt.org/1.0/docs/Publishing.html

#11


1  

Using

使用

sbt -Dhttp.proxyHost=yourServer-Dhttps.proxyHost=yourServer -Dhttp.proxyPort=yourPort -Dhttps.proxyPort=yourPort

works in Ubuntu 15.10 x86_64 x86_64 GNU/Linux.

适用于Ubuntu 15.10 x86_64 x86_64 GNU/Linux。

Replace yourServer by the proper address without the http:// nor https:// prefixes in Dhttp and Dhttps, respectively. Remember to avoid the quotation marks. No usr/pass included in the code-line, to include that just add -Dhttp.proxyUser=usr -Dhttp.proxyPassword=pass with the same typing criteria. Thanks @Jacek Laskowski!. Cheers

用正确的地址替换您的服务器,不使用Dhttp和Dhttps中的http://或https://前缀。记住要避免使用引号。代码行中不包含usr/pass,只需添加-Dhttp即可。proxyUser = usr -Dhttp。proxyPassword=以相同的类型通过。拉斯科夫斯基@Jacek !谢谢你。干杯

#12


1  

I found that starting IntelliJ IDEA from terminal let me connect and download over the internet. To start from terminal, type in:

我发现从终端开始的IntelliJ IDEA可以让我通过互联网连接和下载。从终端开始,输入:

$ idea

美元的想法

#13


0  

On Mac OS X / El Capitan you can set java environment variables:

在Mac OS X / El Capitan上可以设置java环境变量:

$launchctl setenv _JAVA_OPTIONS "-Dhttp.proxyHost=192.168.1.54 -Dhttp.proxyPort=9999"