Where can I set proxy for SBT in Intellij IDEA? - scala

I am using Intellij IDEA 14.1.3 edition and have installed Scala plugin. When creating SBT project, it reports the following error:
Error:Error while importing SBT project:
...
::::::::::::::::::::::::::::::::::::::::::::::
:: org.fusesource.jansi#jansi;1.11: not found
::::::::::::::::::::::::::::::::::::::::::::::
:::: ERRORS
Server access Error: Connection timed out: connect url=http://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
Server access Error: Connection timed out: connect url=http://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
Server access Error: Connection timed out: connect url=http://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries
(see C:\Users\xiaona\.sbt\boot\update.log for complete log)
Error: Could not retrieve jansi 1.11
See complete log in C:\Users\xiaona\.IdeaIC14\system\log\sbt.last.log
After referring this post, I see the root cause should be that I use proxy to connect internet.
But in SBT setting screen:
I can't find a place to set proxy. Where can I set proxy for SBT in Intellij IDEA?

Add -Dhttp.proxyHost=<proxy_server> -Dhttp.proxyPort=<proxy_port> to VM parameters
Read documentation for more info

Basically there are three ways of setting the proxy. Each of them seems to affect a different part of the IDE.
For all following three methods I recommend setting both, http and https, since most connections to repos are established using https nowadays:
-Dhttp.proxyHost=yourProxyAdress
-Dhttp.proxyPort=yourPort
-Dhttp.proxyUser=yourUsername
-Dhttp.proxyPassword=yourPassword
-Dhttps.proxyHost=yourProxyAdress
-Dhttps.proxyPort=yourPort
-Dhttps.proxyUser=yourUsername
-Dhttps.proxyPassword=yourPassword
1. Build Tools
Setting the proxy under "Build, Execution, Deployment" > "Build Tools" > "SBT" > "VM parameters" affects the SBT process that is executed after editing the build.sbt file and refreshing the latter. Also, this is used for indexing (and therefore auto completion). This setting will also affect the download of SBT itself in the version you selected during project setup.
2. Other Settings
Aditionally, I used the setting under "Other Settings" > "SBT" > "VM parameters"
3. Setting the proxy globally
Another way would be to set the proxy settings globally with your JAVA_OPTS as described here.

Add parameter VM
-Dhttps.proxyHost=hostName
-Dhttps.proxyPort=portUse
-Dhttps.proxyUser=proxyName
-Dhttps.proxyPassword=proxyPaword
It work for me

In my situation I have tried all above solutions, but they did not work.
In the end I have configured HTTP proxy for the whole IntellJ, and that have resolved my issues.
Settings > Appearance & Behaviour > System Settings > Http Proxy

If you are running a sbt-based scala project you may need to add the proxy in the run configuration of the project:
Run -> Edit configurations...->->VM parameters

I was seeing this same error message and tried all the suggestions mentioned in multiple (related) threads. I was able to finally resolve the problem by setting up the HTTP Proxy directly in IntelliJ. Here's what my settings look like (Note: specify your network username and password in the corresponding boxes):-

It seemed that in my case, something was picking up the environment variables http_proxy and https_proxy. Correctly setting (or in my case, unsetting, as I did not wish to use a proxy) these variables solved the proxy errors I was getting.

Related

Insecure HTTP request is not supported, sbt compile on intellij

I'm new to Scala and Maven and SBT, I don't know what's wrong with my settings, but I can use sbt cli to compile this project. I need Intellij's sbt to compile it so it can index stuff properly. but every time I run sbt it pops the error below at some point.
insecure HTTP request is unsupported
'http://nexus.example.com/repository/maven-releases'; switch to HTTPS
or opt-in as ("example nexus" at
"http://nexus.example.com/repository/maven-releases").withAllowInsecureProtocol(true),
or by using allowInsecureProtocol in repositories file
I have no idea how I can possibly trace or fix this error but I tried various Maven settings mentioned in SoF like this
Apparently my problem roots in Intellij using some sort of internal Maven with obscure settings that I cannot find to touch (because I had no mvn installed but Intellij had no problem running sbt!).
How should I force intellij to use system mvn or it's settings? or just check if it already is?

Setting up IntelliJ with Scala and SBT

I am trying to setup intellij with scala and sbt for development. I have already installed scala and SBT plugins on the IDE. However, when I try to create a new scala and sbt project, the build.sbt file shows the following errors:
Cannot resolve symbol :=
Cannot resolve symbol name
Cannot resolve symbol version
Cannot resolve symbol scalaVersion
Here is my build.sbt file which was created by the IDE itself:
name := "setup"
version := "1.0"
scalaVersion := "2.12.2"
The following are the steps I followed for creating the project:
Step One: File -> New Project
Step Two: Choose Scala from the left hand side panel and choose SBT on the right hand side panel (i.e SBT-based Scala project) and click Next.
Step Three: Fill in the project details and click Finish. ( Scala version -> 2.12.2, SBT version -> 0.13.13)
IntelliJ version - IntelliJ IDEA 2017.1.3
Edit:
Whenever I am trying to create a new project, I get the following error :
Error:Error while importing SBT project:<br/>...<br/><pre> https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.fusesource.jansi#jansi;1.11: not found
::::::::::::::::::::::::::::::::::::::::::::::
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries
(see C:\Users\xxxxxx\.sbt\boot\update.log for complete log)
Error: Could not retrieve jansi 1.11
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384M; support was removed in 8.0</pre><br/>See complete log in C:\Users\xxxxx\.IntelliJIdea2016.2\system\log\sbt.last.log
the Log file has the following content:
Getting org.fusesource.jansi jansi 1.11 ...
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
You probably access the destination server through a proxy server that is not well configured.
:: problems summary ::
:::: WARNINGS
Host jcenter.bintray.com not found. url=https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.11/jansi-1.11.pom
Host jcenter.bintray.com not found. url=https://jcenter.bintray.com/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar
Host repo.typesafe.com not found. url=https://repo.typesafe.com/typesafe/ivy-releases/org.fusesource.jansi/jansi/1.11/ivys/ivy.xml
Host repo1.maven.org not found. url=https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/
**
So I think this is an issue with my proxy settings and I definitely need to use the proxy. Is there a way to solve this??
Any help would be appreciated. Thank you.

Can't use akka in IDEA plugin development

When I develop an IDEA plugin, I want to use akka, but have some problems.
I created a demo project here: https://github.com/freewind/idea-plugin-akka-demo
You can just clone it and reproduce the problem on your computer. (Notice the Setup section)
And I copy the problem here:
Problems
1. Can't use default akka configuration
If I removed:
src/main/resources/application.conf
src/main/scala/freewind/MyAkkaConfig
and run this plugin, it will report this error when starting:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
com.intellij.diagnostic.PluginException: No configuration setting found for key 'akka'
[Plugin: com.yourcompany.unique.plugin.id]
2. Can't load the configuration from file
Then I copied the reference.conf from akka jar, to src/main/resources/application.conf, but it still report the same error. Seems akka in IDEA plugin can't find this file automatically.
3. ClassNotFoundException: akka.actor.LightArrayRevolverScheduler
So I have to use MyAkkaConfig.scala to hardcode the configuration in scala code, but this time, it reports another error:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
com.intellij.diagnostic.PluginException: ClassNotFoundException: akka.actor.LightArrayRevolverScheduler
[Plugin: com.yourcompany.unique.plugin.id]
The akka.actor.LightArrayRevolverScheduler is used in MyAkkaConfig.scala, and is included in akka-actor_2.11:2.3.12:jar. But why IDEA can't load it?
For the 3rd problem, it can be fixed by passing the classloader:
val system = ActorSystem("my-actor", MyAkkaConfig.config, this.getClass.getClassLoader)
But we also can remove the MyAkkaConfig.config, to use the file application.conf under resources

Installing SBT on Win 7 64 bit

I want to install Apache Spark for testing purpose. For that I found out that Scala and sbt are necessary. I downloaded scala msi and installed it. For installing sbt I tried various methods but am unable to do so. Can someone tell me what am I doing wrong. What I did is
Install Scala msi
Download sbt msi and install it.
Set sbt_home and path variable to the location where sbt is extracted. Then I opened cmd to check my sbt version by using sbt sbt-version I am getting the following error **unresolved dependency:
org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries (see C:\Users\ashish-b\.sbt\boot\update.log for complete log) Error: Could not retrieve jansi 1.11 **
Whats wrong in it?
I saw this issue as well when connecting to the internet via a corporate proxy. In this case, sbt couldn't download its dependencies.
We work with a proxy Maven repository for depedencies. Configure sbt to use a proxy repo.
Our sbt repositories file looks like this:
[repositories]
local
local-maven: file:///C:/data/maven_repo/
aaa-ext-ivy-proxy: http://nexus-ext.company.net:8081/nexus/content/groups/ivy-public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
aaa-ext-maven-proxy: http://nexus-ext.company.net:8081/nexus/content/groups/public/
aaa-int-maven-repo: http://nexus-int.company.net:8081/nexus/content/groups/public/
Or you can also configure the proxy server directly for SBT, see this question.

How do I run a maven/eclipse/GWT/playN app in production mode?

There seems to be an issue if you want to launch a playN/GWT/maven app from eclipse in production mode using the following procedure:
Right click on playn-showcase-html and select Goolge-GWT Compile
Compiling module playn.showcase.Showcase
Resolving com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator
Found type 'com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator'
Found type 'javax.validation.constraints.DecimalMax'
[WARN] Detected warnings related to 'javax.validation.Constraint'. Is validation-<version>.jar on the classpath?
Specify -logLevel DEBUG to see all errors.
[WARN] Ignoring unresolvable annotation type javax.validation.Constraint
Compiling 1 permutation
Compiling permutation 0...
Compile of permutations succeeded
Linking into /Users/bryan/dev/playn-samples/showcase/html/target/playn-showcase-html-1.0-SNAPSHOT/showcase
Link succeeded
Compilation succeeded -- 19.459s
Anyone know what these warnings are about?
Right click on playn-showcase-html and select Run As web application
Go to URL http://127.0.0.1:8888/Showcase.html in your browser and you'll get an error that says GWT module 'showcase' may need to be (re)compiled.
The only way around this appears to be if you swap steps 1 & 2, but that just seems backwards. I think the problem is that the when you run the web app from eclipse that the gwt maven plugin is compiling/deploying the artifacts again which step on your previous GWT compile step.
Anyways, this isn't a huge deal since you can reverse the order of steps to get it to work, but I was just curious if anyone has found a solution to this.
I suggest that you try to compile/run it with maven directly, not through Eclipse, first go to the root directory of your game and do the following:
mvn clean package
that should compile your game without problems, and then
mvn test -Ptest-html
and that should run your game in http://localhost:8080/
Hope this helps, and I strongly suggest that use maven directly whenever you can, because Eclipse has a lot of incompatibility problems with some things.