I'm having trouble getting IntelliJ to recognize Ammonite imports in my Scala script. This is a new feature, reported here, where there are also instructions. I followed the instructions and I started a new sbt project in IntelliJ to try it out, but it's not working.
I see the Ammonite dependencies in the project's "External Libraries", which I specified in the build.sbt
:
libraryDependencies += "com.lihaoyi" %% "ammonite-ops" % "1.0.3"
libraryDependencies += "com.lihaoyi" % "ammonite" % "1.0.3" cross CrossVersion.full
The (quite simple) project seems to successfully build. I also specified that Scala worksheet files should be treated as "Always Ammonite".
All this, yet the IDE shows the script like:
What more do I need to do to get this to work?
Versions:
I had similar issues with IntelliJ, so let me share how I made it work.
My versions:
Now, I started from the same code as you have, with updated version of dependency 0.6.7
.
Already now pressing the green arrow to next to 1st line runs Ammonite. The dependencies are downloaded and link is displayed. That is mandatory step for IntelliJ to recognize that new jar is available.
Also at this stage Intellij shows me a small popup with information that I can import the jar. I did not use it.
To make IntelliJ recognize the imports, I press Alt+Enter Show Intention Actions on the broken com.lihaoyi::scalatags:0.6.7
dependency and use Create library from jar...
This makes Intellij recognize the library, imports and it can start giving you hints.
The library is added to the Project's dependencies (Ctrl+Alt+Shift+s). You can see also dependencies coming from other files below.