How to use my classes from Scala worksheet in IntelliJ CE with Scala plugin?

I cannot use my classes from the Scala worksheet in IntelliJ CE with the Scala plugin.

I do the following:

  • Create a Scala SBT project.

  • In src / main / scala, create the test1 package.

  • In this package, create a class

 package test1 class TestClass { } 
  1. In the same package, create Scala worksheet ws1.sc, create a ws1 object inside it, add a couple of expressions inside it. It is working.

Screen shot 1

  1. When I add new ScalaTest to the new ScalaTest object, IntelliJ adds import test1.ScalaTest , but the worksheet evaluation does not work.

Screenshothot 2

If I add package test1 to my sheet, it doesn’t work at all, with the warning β€œThe package name does not match the directory structure, this may cause a problem with resolving classes from the file”

Screen shot 3

Any ideas how to use my classes from a worksheet?

+6
source share
2 answers

You can use eclipse compatibility :

Settings β†’ Languages ​​and framework β†’ Scala β†’ Worksheet β†’ use eclipse compatibility mode

+5
source

You should mark "Make a project" next to "Interactive mode"

+2
source

Source: https://habr.com/ru/post/977393/


All Articles