Cannot Resolve Ammonite Main Methods in Intellij

508 Views Asked by At

I want to use @main like described here: https://ammonite.io/#ScriptArguments

@main
def all() = {
  ...
}

It cannot be resolved in Intellij. I couldn't find an import. I have added these dependencies:

libraryDependencies ++= Seq(
           "com.lihaoyi" %% "ammonite-ops" % "1.6.9",
           "com.lihaoyi" % "ammonite" % "1.6.9" cross CrossVersion.full
        )

Is there a way to achieve this?

1

There are 1 best solutions below

2
On BEST ANSWER

Something like this should work:

import ammonite.main.Router.main

@main
def all() = {
  print("hey")
}

all()

Also, make sure you create Scala Worksheet (.sc) and not Scala Class (.scala) to allow IntelliJ to help you with ammonite imports.