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>
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.
The Scala REPL (“Read-Evaluate-Print-Loop”) is a command-line interpreter that you use as a “playground” area to test your Scala code.
We can start Scala REPL by typing scala command in console/terminal.
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).
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With