Reputation: 22166
I am new to both IntelliJ and Scala. I am attending the course "Functional Programming Principles in Scala" on Coursera. I downloaded the zip file for the sample assignment, which contained a sample Scala project.
I imported the project successfully (I guess) in IntelliJ. However, when I right-click on a package in the project explorer, there are no Scala-related templates. I can only select "New Java class", XML files and some forms.
Does anyone know why this happens and if there is another way to create a new Scala class or object from a template?
Thanks.
Upvotes: 10
Views: 7268
Reputation: 593
Yes, you need to make the scala directory a source directory (in Menu / Project structure / Modules ) but I also had to do the following:
Now my context menu gives me New / Scala class and so on.
Upvotes: 3
Reputation: 131
For me it works as following:
Right clicked on src and selected "mark directory as" -> source root.
Upvotes: 9
Reputation: 11
Same issue (and solution) as @cwadeevans.
A project named "Week 1" did not show Scala files in the context menu "New". The solution was to delete the project and create a new one named "Week1".
Upvotes: 0
Reputation: 141
I had this problem everytime I created a new project with spaces in the name. eg "Hell Wev". Using "HellWev" as a project name seems to work fine
Upvotes: 2
Reputation: 41
Once you've created a project and sbt has finished initializing, try creating another project. It should show up correctly in the new project, as it worked for me. It seems to be some kind of caching issue though Invalidate Caches/Restart didn't help me. Also, ensure that source directories are marked properly (source folders appear in blue color, test sources are in green).
Upvotes: 2
Reputation: 7980
This may also be a caching issue.
If so, try File
then Invalidate Caches / Restart
Upvotes: 4
Reputation: 22166
Import the project by selecting its build.sbt
file - not the project folder, not the eclipse project file. Then everything is imported correctly.
Upvotes: 10