Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala:console is worse than Scala's own REPL?

Using maven-scala-plugin I can run Scala console with all dependencies as:

mvn scala:console

However, what I get is much more poor REPL than Scala's own one (the one you get when run scala without arguments). E.g. it misses auto-completion and history, arrow keys just print their code (instead of moving cursor), etc.

Is it known issue or just a misconfiguration in my setup? If first, what are alternatives to scala:console (i.e. REPL with all dependencies and compiled code)?


Plugin configuration in my pom.xml:

<plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <version>2.15.0</version>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>testCompile</goal>
        </goals>
        <configuration>
          <args>
            <arg>-make:transitive</arg>
            <arg>-dependencyfile</arg>
            <arg>${project.build.directory}/.scala_dependencies</arg>
          </args>
        </configuration>
      </execution>
    </executions>
</plugin>
like image 996
ffriend Avatar asked Jun 13 '14 12:06

ffriend


People also ask

Does scala have a REPL?

The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.

What does the scala REPL stand for?

The Scala REPL (“Read-Evaluate-Print-Loop”) is a command-line interpreter that you use as a “playground” area to test your Scala code.

How do I get scala prompt?

We can start Scala REPL by typing scala command in console/terminal.


2 Answers

the version org.scala-tools:maven-scala-plugin:2.x of the plugin is deprecated/dead (due to EOL of scala-tools.org, maven3 convention,...).

Try

    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.0</version>

(Note : I'm the author of both plugins).

like image 108
David Bernard Avatar answered Sep 23 '22 17:09

David Bernard


It's interesting how asking questions on SO makes you think in another direction and find answers yourself. It turns out I missed error message on REPL start:

Failed to created JLineReader: java.lang.NoClassDefFoundError: scala/tools/jline/console/completer/Completer Falling back to SimpleReader.

Which quickly leads to solution - one just needs to add JLine to dependency list:

<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>jline</artifactId>
  <version>2.9.0-1</version>
</dependency>
like image 43
ffriend Avatar answered Sep 21 '22 17:09

ffriend