Insecure HTTP request is not supported, sbt compile on intellij - scala

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?

Related

Inside IDE(IntelliJ), could not find sbt dependies from External Libraries

I am starting a Scala project and I'm using SBT and Intellij 2020.2.3 as my IDE.
I have the following build.sbt file from the project, but I can't seem to get the dependencies in the Idea IDE "External Libraries" section to show up in "libraryDependencies" of SBT after running "sbt update".
The Idea version is that:
The Idea External Libraies are that:
The Sbt libraryDependencies are that:
In my experience , Intellij is very slow to pickup on dependencies and display them.
Bare in mind this is not a reflection on sbt , and asides for the annoyance, you should still be able to sbt compile from the console.
That is the first thing I suggest you test. If you can compile , that means the dependencies were downloaded, are available on the classpath, and its just a matter of getting Intellij to recognize that
You can try one of 2 things, hover over the dependencies in your build.sbt file and you might see a refresh project option , or you can go to module section in project settings and reimport

IntelliJ with SBT plugin: Error Resolving [com.mycompany.mypackage]

I am trying to build a SBT based Scala project. The project has dependencies on packages on my company's local maven server. From within the company's network, I was able to compile/package(from cli and IntelliJ) the project successfully yesterday.
Today from home from command prompt, When I do:
sbt assembly
to build the repo it works fine.
But when I build from IntelliJ or do:
sbt compile|package
It is hitting the maven server and failing. My question is if the packages are already in the cache - ~/.ivy2/ then why maven server is hit. Is there a way to avoid server hit?
Doing a little search, found the answer
$ sbt "set offline := true" run

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.

Intellij unable to resolve references to a specific jar file

In a given project that is driven by sbt there is some kind of corruption in the project libraries specifically for a MavenLocal repository used for kafka-spark-9.7.2.jar in which:
references to the classes provided by that jar are marked as "symbol not found" by the editor parser
however the editor (strangely) does offer to import the classes
but after accepting the import, the symbols are still marked in red as unresolved.
The following attempts to "clean things up" have already been performed:
Build | Make Project
Build | Rebuild Project
In addition I have verified that the project does build from
sbt package
on the command line
UPDATE After re-running sbt gen-idea the librraries are still not found by the Parser. yet the libraries exist -even IJ knows about them as shown in the following screenshot. Why is it that IJ can find the library
C:\Users\S80035683\.ivy2\cache\org.apache.kafka\kafka\jars\kafka-0.7.2-spark.jar!\kafka\api\FetchRequest.class
However IJ is unable to resolve any classes from that library in the Parser?
You have to build the project for Intellij, try to do this in your project root:
sbt idea with-sources=yes
This should build the project structure from scratch and add the right dependencies, usually I refresh the project after adding a dependency or a jar.
Edit:
To use the command you need this plugin, otherwise you can use gen-idea but I used it only a few times and I'm not sure how it will work out.
Edit2:
There was some confusion, first, for the IDEA SBT console you don't need to prepend the sbt command since you already are inside sbt:
If you have the sbt plugin for idea you can use gen-idea with-source=yes (without prepending sbt)
From the terminal, either you go to your project root and type sbt to enter the sbt console and use gen-idea or idea with-sources=yes (without prepending sbt)
or directly sbt gen-idea or if you have the plugin sbt idea with-sources=yes (prepending sbt)
To reach the sbt console inside idea you need to install the sbt plugin on preferences -> plugin and search for sbt and then View -> Tool Windows -> SBT Console:
To start the console click on the play button, to kill the console on the skull.
I had the same problem. I fixed it by directly writing the CLASSES and SOURCES of the problematic library. This can be found in .idea/libraries/SBT__<problematic library>_jar.xml

Can I have an AnnotationProcessor defined in maven which will cause compilation errors in my IDE?

Background: I'm adding some annotations to one of our test modules such that everything in a specific package needs to be annotated. I have already written an AnnotationProcessor which does this.
The problem: My processor successfully works for me when I run mvn generate-test-sources and mvn test. However, I would like it to show errors in our development IDEs (Eclipse and IntelliJ). I have not tried with IntelliJ, but with Eclipse, I'm having issues. I've installed m2e-apt, but when I toggled between the settings it didn't seem to work. A test which was not properly annotated was not getting errors (and other modules which didn't inherit the processor plugin got NPEs when being built).
What are my options for having streamlined capability to show errors in IDEs for AnnotationProcessors?