Intellij 14.1.3 and SBT - scala

When the auto-import of SBT , it marks me " Unresolved dependency" , and I do not understand why !!!
Yet the jar files are in the directory .ivy2 .
Can you help me.
best regards, Alexis

Try the EAP version if the Scala plugin.

It might be a bug. Perhaps more success joining that discussion on devnet.jetbrains.com.

Related

Import Twitter/chill to Scala code using Intellij IDE

I have to do some assignments with Scala and I'm a newbie for this language.
In the assignment, the prof requests me to implement serialization and deserialization, using twitter/chill.
https://github.com/twitter/chill/
However, I don't know how to import the libary into my IDE Intellij.
Each time I use val instantiator = new ScalaKryoInstantiator.
IDE notify me that: Cannot resolve symbol ScalaKryoInstantiator.
Could anyone can help me to resolve this issue?
Thanks and Best Regards,
Long.
One way to add a library in a Scala project, if you use sbt, is to add an sbt dependency. Most libraries and jars can be found and downloaded from the maven repositories: https://mvnrepository.com/artifact/com.twitter/chill_2.9.2/0.2.3
If you click the sbt tab on the page above, maven gives you a code snippet which can be directly pasted into your build.sbt. In order to compile and run your project using sbt, open the terminal in the directory where your build.sbt is located and use the "sbt run" command.
If you don't use sbt, download the jar from maven and follow the instructions in this answer: How to add external library in IntelliJ IDEA?

Multiple scala libraies causing error in intellij?

I am using intellij 14 with scala 2.11.6 installed using home brew and symlink using
ln -s /usr/local/Cellar/scala/2.11.6/libexec/src /usr/local/Cellar/scala/2.11.6/src
ln -s /usr/local/Cellar/scala/2.11.6/libexec/lib /usr/local/Cellar/scala/2.11.6/lib
mkdir -p /usr/local/Cellar/scala/2.11.6/doc/scala-devel-docs
ln -s /usr/local/Cellar/scala/2.11.6/share/doc/scala /usr/local/Cellar/scala/2.11.6/doc/scala-devel-docs/api
I tried running a simple hello world but run into the following issue.
Error:scalac: Multiple 'scala-library*.jar' files (scala-library.jar, scala-library.jar, scala-library.jar) in Scala compiler classpath in Scala SDK scala-sdk-2.11.6
Edit:
So I check the compiler class path on global libraries and apparently there are multiple scal-library.jar
file:///usr/local/Cellar/scala/2.11.6/idea/lib/scala-library.jar
file:///usr/local/Cellar/scala/2.11.6/lib/scala-library.jar
file:///usr/local/Cellar/scala/2.11.6/libexec/lib/scala-library.jar
Does anyone know why?
Maybe you have used
/usr/local/Cellar/scala/2.11.6/
as the path for Scala SDK?
When you install scala with homebrew that path will contain not only the scala libraries, but also a symlink with the relevant libraries for intellij. So if you use the top-level install directory intellij will find the libraries twice.
Instead you should use
/usr/local/Cellar/scala/2.11.6/idea/lib
I had the same issue than you experimented and the solution, actually very easy, was actually erasing the .idea folder from the project, the problem is that the configuration inside of this folder (containing the set ups for example for the test, VCS, the runs, etc) gets corrupted with double entries (probably cos you update your Scala version), once you do this and reopen the project in Intellij the IDEA will generate a fresh new configuration for you.
This worked for me.
I'm using Idea 2019.2.2 and Windows 10.
In the folder .idea/libraries/ I had two files: sbt__org_scala_lang_scala_library_2_13_0_jar.xml and sbt__org_scala_lang_scala_library_2_13_0_jar2.xml.
I deleted the second file.
Then I opend the first one and there were duplicate lines:
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/jline/jline/2.14.6/jline-2.14.6.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.0/scala-compiler-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.0/scala-compiler-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.13.0/scala-reflect-2.13.0.jar" />
So I deleted duplicates and errors disappeared.
Hope this will help someone else.
I also ran into that error. The fix I found was to remove the duplicate scala-library in the .iml file generated by intellij.
Basically I located the relevant .iml file by grepping the scala version, and found that two scala-library in that file. I removed the scala 2.11 version, and then it works.
Remove the following line in build.sbt:
...
scalaVersion := "2.13.0"
...
Try rebuilding and running it again
2019 update... I'm running Ubuntu Linux and IntelliJ community 2019.1 with sbt 2.13.1 and got the exact same error. I also found that if I built directly from sbt with "runMain package.MyClass" it worked, so I knew it must be an IntelliJ problem, not a "real" problem.
Anyway, I found the file .idea/libraries/sbt.. lots of crazy long name ... scala_library_2_13_1_jar.xml.
In it, there was an XML block , and in that block, two entries were duplicated:
I first noticed the scala-library one, and after deleting that, the error report came up about the scala-compiler duplicate too.
After deleting both duplicates, my build is now working.
To fix the problem go to project structure in intellij and go to global libraries
It should be like this
After that remove all the scala SDKs by hitting the - mark
Next, click the + and choose your Scala SDK version to add
After that please make sure to apply the changes and re-run the program
You have JAR files from multiple versions of scala-library.jar. In order to make the error go away you will have to delete the duplicates. To figure out which version you want to keep, you can view the manifest file inside each JAR:
META-INF/MANIFEST.MF
Inside the manifest file you should see something like this:
Manifest-Version: 1.0
Class-Path:
Implementation-Title: Scala-Library
Implementation-Version: 2.11.4
The error is happening because IntelliJ cannot figure out which version of a given Scala class to use.
Delete multiple versions of scala-library in sbt, leaving one.
Having similar symptoms, but on a Ubuntu machine, not using brew:
I am using /usr/share/sbt/bin/sbt-launch.jar as launcher. To fix the mentioned problem, I've had to purge the directories 1) project, 2) target and 3) .idea of the relevant Scala projects, doing sbt refresh in IntelliJ (View - Tool Windows -> sbt, hit the Reimport all sbt projects icon), and rebuild all modules afterwards.
As a last step, when the error occurs further, switch over to Ubuntu shell / terminal, and do a sbt clean compile in the problematic project folder. Fix the compile issues if some are occuring. If this does not help, change scalaVersion in build.sbt e.g. from 2.12.9 to 2.12.8 (the error occurs more often with 2.12.9), remove scalaOrganization definition (but keep organization). Repeat the sbt refresh of IntelliJ. OMG.
This worked for me:
In IDEA
Preferences -> Plugins -> Scala -> Update
Restart IDEA

IntelliJ plugin for cucumber-scala

I am running Cucumber scala project in IntelliJ
IntelliJ IDEA - 13.0.2
I couldn't find separate plugin called cucumber for scala
In my project I am getting cannot resolve message for cucumber as below
Could see below errors as well
Existing plugins installed
What could be the solution
Cheers
You are missing dependencies for cucumber-core and cucumber-scala, please have a look at the documentation and add them to your build.sbt file.
Update:
There is a newer version available for sbt-cucumber-plugin (0.8.0): https://github.com/skipoleschris/xsbt-cucumber-plugin. Maybe that solves your problems.
Did you try the gen-idea plugin to create the IntelliJ IDEA project files ?

Scala Lift - SBT compilation error (Sources not found)

I have my lift project working perfectly on my local windows machine, and am now attempting to put it live on our RHEL5 server.
The project is in
ROOT/lift24
When I attempt to run
./sbt update ~jetty-run
in the lift24 folder I get the following after successful update:
[info] Compiling main sources...
[error] source file '/lift24/src/main/scala/code/api/UserAPI.scala;src/main/scala
/code/snippet/RoomDataSnippet.scala;src/main/scala/code/comet/UserServer.scala;
src/main/scala/code/comet/StreamServer.scala;src/main/scala/code/rogue
/QueryField.scala;src/main/scala/code/snippet/StreamSnippet.scala;src/main/scala
/code/comet/PresentationServer.scala;src/main/scala/code/comet
/PresentationComet.scala;src/main/scala/code/snippet/RoomCometSnippet.scala;src
/main/scala/bootstrap/liftweb/Boot.scala;src/main/scala/code/comet/ChatComet.scala;src
/main/scala/code/api/RoomAPI.scala;src/main/scala/code/snippet/UserSnippet.scala;src
/main/scala/code/comet/ChatServer.scala;src/main/scala/code/comet/StreamComet.scala;src
/main/scala/code/comet/UserComet.scala;src/main/scala/code/snippet
/ChatSnippet.scala;src/main/scala/code/snippet/PresentationSnippet.scala'
could not be found
All of the files are in
ROOT/lift24/src
It seems this is a path issue, but do not know how to tell sbt where to look.
Thanks in advance for any help, much appreciated :)
To fix this issue, just run:
sbt -clean
:)

Solr compiling error in eclipse

I check out solr to eclipse, but got the compilation error:
The method setXIncludeAware(boolean) is undefined for the type DocumentBuilderFactory
Does anyone know what's wrong ? Thanks
Jeff Zhang
javax.xml.parsers.DocumentBuilderFactory.class
is included in JRE 1.6 and also in xml-apis-1.0.b2.jar.
The version in the jar is from an older version. Remove the dependency on the jar and see what happens.