Add Scala SDK to module Follow
You used to be able to add Scala to a module using Add Framework Support but Scala is no longer listed as a framework. How do you add Scala as a framework/facet/whatever it's called now? For example, I'm getting "Skipping files without a Scala SDK" now that I've upgraded to Intellij 15.
Please sign in to leave a comment.
I'm experiencing the same issue, and it's very unproductive. I'm on IDEA 2017.3, Scala plugin enabled.
The way it manifests is that after a certain IDEA 2017.x upgrade (not sure which minor version), all our Scala codebases were somehow reset to not be attached to a Scala SDK. IntelliJ recognizes the Scala files as such and does all the IntelliSense highlighting but won't compile the project with the following warning:
Add Framework Support does NOT list Scala as a Framework (despite of me having used it for a long time prior to the upgrade)
For most projects, a dialog will eventually pop up asking me if I want to add the library to the project. And that's on a per-module basis, which for multi-module projects is very cumbersome and time sucking.
If I add Scala library as a dependency manaully in the Project Structure view, it will disappear on next SBT refresh.
Happy to file this as a bug in the issue tracker, this has been a major source of frustration on our team.
Still having this problem in IDEA 2019.2 with scala sdk 2.13.0. Cannot add scala as FrameWork to project or in 'Modules' under Project Settings.
Had the same problem when upgrading from 2017.3 community to 2018.1 ultimate.
For me it helped to delete all .idea folders before opening with IDEA 2018.1 ultimate.
When using "Add Framework Support" You should see Scala in the list
Do you have the Scala plugin in the list of plugins? Is it turned on?
Can you create a Scala Project?
Facing the same issue
Same here. Scala plugin enabled; I can create a Scala project. "Add framework support..." lists Groovy, Kotlin/JVM, Kotlin/JS, Maven; NOT Scala.
Every once in a while I encounter this problem. Especially after updates of IDEA and the Scala plugin. Then I solve it, and forget it; encounter it again etc.
The support pages do not provide helpful solutions.
You can add Scala SDK as global library for your project in `Project Settings -> Platform Settings / Global Libraries -> Add -> Scala SDK`
I am facing the same issue as described by Greg. No option to add Scala in the Add Framework Support. Scala plugin is enabled.
This time I solved something:
In Project Settings | Modules there was a module `main` and an application module therein.
I removed the latter, and now the Scala compiler is run, at least.
But the build.sbt file is ignored, and Project Settings | Projects lists 41 issues with sbt libraries not being used. I opened the "sbt" window, clicked on the button "refresh all sbt projects"; that fixed the 41 issues. But: the application module was back there again, as well as the "Warning:scala: skipping Scala files without a Scala SDK in module(s) ...".
Please file a bug at https://youtrack.jetbrains.com/issues/SCL with the sample project to reproduce. Specify IntelliJ IDEA, Scala and SBT versions you are using.
Encountered this problem when recently upgrading from 2019.2 to 2019.3.
Resolved it by going to "File -> Project Structure -> Global Libraries" and removing 'scala-sdk-2.11.8' and then re-adding it back. Had do this for each project.
Same issue for me still. The scala plugin is installed, but I don't have the option to add framework support for it. Anyone else still having this issue?
What us the module type you are trying to add Scala SDK to? Please share the screenshot from the Project Structure | Modules dialog.
Serge Baranov, thanks for the response! Here's what I have in modules:
In the second image, it doesn't recognize the gibberish as bad syntax, nor does it let me hop into function definitions.
My end goal is to use gatling with IntelliJ and be able to get normal IDE features like "code-hopping" (CMD+click functions and hop to their definitions) as well as syntax error correction suggestions (before compile time). Here is the gatling archive I downloaded: https://gatling.io/open-source. I tried to use "New project from existing sources", but IntelliJ doesn't recognize the Scala code that's in `gatling-charts-highcharts-bundle-3.3.1/user-files/simulations` or the code that I generate. `gatling-charts-highcharts-bundle-3.3.1/bin/gatling.sh` is able to compile the code just fine according to its own internal structure, but IntelliJ can't see that.
I understand that the recommended approach is to use sbt/maven and all, but I was hoping as someone just starting out with gatling and scala that I could get simple IDE features up and running. Unfortunately, I've spent hours on this to no avail.
Try creating an empty project first, then add a new Java module manually and configure the source/content roots for this module: https://www.jetbrains.com/help/idea/configuring-content-roots.html .
It looks like automatic import didn't detect it as Java module and it's probably recognized as the static WEB module instead, therefore you can't add Scala to it.
Hi Serge Baranov, thanks for the tip. Now I'm getting somewhere!
What now works: The IDE is now checking syntax and has access gatling-charts-highcharts-bundle-3.3.1/user-files/simulations to be a Module -> Content Root -> Source Folder
What still doesn't work: The IDE is unable to recognize the jars in gatling-charts-highcharts-bundle-3.3.1/lib which contain the gatling code. Because of this, the gatling source code is still unrecognized in the IDE.
What I have tried but did not resolve this issue:
1. In the Modules tab, adding gatling-charts-highcharts-bundle-3.3.1/lib as both a "Resource" and a "Source".
2. In the Libraries tab, I tried to add this, but it only lets me add base scala jars:
Any tips to get this last part working? Thanks!
You should not configure library folders as source or resource roots.
Adding all the jars to the module dependencies should work: https://www.jetbrains.com/help/idea/creating-and-managing-modules.html#working-with-module-dependencies .
Ah! I didn't see those tabs 🤦♂️. That worked. Thanks a million! This will save me so much dev/debugging time 🙏.
I have a multi modules maven scala project. And once in while IntelliJ seems to not be able to automatically add Scala framework support to all modules.
As a workaround, I had to manually go in each module and add the scala framework support. This is so time consuming and annoying.
Shouldn't intellij just be able to do that for me based on the project pom files ?
It would depend on your pom files configuration. If you have Scala dependency there, IntelliJ IDEA will add it to the modules.
I have it as a dependency in the parent pom. Do I need to add it to each single maven module instead ?
If the project builds in the command line Maven, but not in IntelliJ IDEA, please report a bug at https://youtrack.jetbrains.com/issues/SCL and attach a small sample to reproduce.
It builds fine at command line. But not in IntelliJ IDEA. I think it is the multi-module setup. Looks like I have to explicitly set the scala-library dependency in each module. Can you confirm whether that is the expected behavior?
No, it's not expected. IDE should behave as close as possible to the command line builds. If it works differently, it's a bug that needs to be fixed.
I found the issue in my project. The scala-maven plugin was configured to use a different scala version than the one imported as dependency.
Basically the scala plugin was bringing in 2.11.11-bin-typelevel-4 at the same time I had an explicit dependency on 2.11.12.
Removing the following two lines made things to work.
I guess that incosistency prevented IntelliJ from adding the scala framework to the project.
Perhaps in situation like this one, would be nice if IntelliJ could simply raise a warning saying that
it detected two different scala-library versions thus it could not select which one to add as framework.
That will make it much easier to detect and resolve issues like this. Otherwise it is just try/run.
Thanks for the details. Could you please file an enhancement request at https://youtrack.jetbrains.com/newIssue?project=SCL?