Questions tagged [scala-script]
19 questions
23
votes
2 answers
What is the difference between scala classes, scripts and worksheets in Intellij-idea?
I'm using Intellij-idea for scala programming (with sbt plugin).
I want to know what is the difference between scala classes, scala scripts and scala worksheets. When we use each of them?
This will be very nice if you can explain it by a simple…

Omid Ebrahimi
- 1,150
- 2
- 20
- 38
11
votes
2 answers
Scala script doesn't run on Ubuntu
I have a previously working Scala script that when I try to run it on a new PC, the compilation fails.
So I made simple script to test:
#!/bin/sh
exec scala -J-Xmx2g "$0" "$@"
!#
println("test")
And trying to run it I get:
test.scala
error:…

MartasSan
- 155
- 1
- 8
9
votes
2 answers
Shorter Scala Script header
It's possible to write shell scripts in Scala by starting a text file with:
#!/bin/sh
exec scala "$0" "$@"
!#
To ease script creation, I would like to write an executable called scalash (perhaps a BASH script) allowing to shorten Scala script…

paradigmatic
- 40,153
- 18
- 88
- 147
3
votes
0 answers
How to use a private Repo with enviroment variables in a scala-cli Script
According to the scala-cli doc you can define a Repo like this:
//> using repository "https://maven-central.storage-download.googleapis.com/maven2"
And you can specify environment variables like this:
//> using publish.secretKey…

pme
- 14,156
- 3
- 52
- 95
3
votes
2 answers
Issues with Scala ScriptEngine inside spark submit application
I am working on a system where I let users write DSLS and I load it as instances of my Type during runtime and these can be applied on top of RDDs. The entire application runs as a spark-submit application and I use ScriptEngine engine to compile…

paulsonvincent
- 49
- 3
2
votes
1 answer
Cannot Resolve Ammonite Main Methods in Intellij
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(
…

pme
- 14,156
- 3
- 52
- 95
0
votes
3 answers
Compiling Scala scripts. How works a Scala script?
Groovy
Groovy comes with a compiler called groovyc. For each script, groovyc generates a class that extends groovy.lang.Script, which contains a main method so that Java can execute it. The name of the compiled class matches the name of the script…

Arturo Herrero
- 12,772
- 11
- 42
- 73
0
votes
2 answers
Running scala script with line breaks in spark-shell
I'm trying to run a scala script through spark shell using the following command:
spark-shell -i myScriptFile.scala
I can get the above command to work when I have single-line commands, but if I have any line-breaks in the script (for readability),…

NicolasCage
- 105
- 9
0
votes
0 answers
Scala Script Engine is not found when run in Test using Mill or SBT
I have a strange behaviour concerning Testing Scala Script Engine.
I have the following code:
val manager = new ScriptEngineManager(getClass.getClassLoader)
val e = manager.getEngineByExtension("scala")
log.info(s"Script Engine: $e from:…

pme
- 14,156
- 3
- 52
- 95
0
votes
0 answers
Avoid recompiling Scalas script
I like the idea of using Scala as a scripting language (https://www.scala-sbt.org/1.x/docs/Scripts.html). However, it always takes a long time even for a simplest Hello World script to run, presumably because sbt is recompiling the script every…

SlavaSt
- 1,493
- 1
- 16
- 19
0
votes
3 answers
Ammonite: how to use another script from an Ivy dependency?
I have an Ammonite Script that I want to deliver in a JAR.
In another project I want to use this Script - but so far with no success.
I tried according to the documentation (sol_local_build.sc):
import $ivy.`mycompany:myproject_2.12:2.1.0-SNAPSHOT`,…

pme
- 14,156
- 3
- 52
- 95
0
votes
0 answers
How to run 'set' or 'source' with Ammonite Script
I want to do the following with Ammonite:
set -a
source .my-env
docker-compose up -d
My Solution looks like:
%("set", "-a")
%("source", "./devops/it.env")
%("docker-compose", ...)
The first 2 lines do not work, I get No such file or…

pme
- 14,156
- 3
- 52
- 95
0
votes
0 answers
sbt scala script setup fail
I'm want setup scala script by sbt ways according to document here.
A error encountered when execute
java -Dsbt.main.class=sbt.ScriptMain -Dsbt.boot.directory=/home/user/.sbt/boot -jar sbt-launch.jar "$@"
Error message:
Getting org.scala-sbt sbt…

LoranceChen
- 2,453
- 2
- 22
- 48
0
votes
1 answer
how to use sbt/amm scala script on pipe operator?
I want to deal with log output with scala script. Like this:
java -jar app.jar | log.sc or java -jar app.jar | amm log.sc
How to write a log.sc deal with app.jar print logs?
motivation
Replace java -jar app.jar > app.log with some smarter way to…

LoranceChen
- 2,453
- 2
- 22
- 48
0
votes
1 answer
Running IntelliJ scala project error
I am not using IntelliJ 15 for a long time, but never ever had such an issue. When I do: New Project -> Scala, then everything works fine, but when I do New Project -> SBT, then I can't even have main, because it gives me this:
Exception in thread…

Cauchy
- 117
- 6