2
votes

Let's suppose I have a file called Main.scala that I want to compile and run.

In a normal environment I can just do scala Main which automatically performs compilation and runs the file.

Now I am trying to deploy scala source code to another Server, on which I am not allowed to install scala. It is just possible to copy files (such as scala-library.jar and scala-compiler.jar) and Java 1.6 is pre-installed.

It would of course be possible to compile to bytecode locally using scalac Main.scala and execute the resulting .class-files using java -cp [...] Main.

For my workflow it would, however, be better if I could just checkout and compile the scala sources on the remote server directly.

Is there any possiblity to realize this compilation task with the tools available or by copying additional binary/jar files?

1
Why do you think checking out the scala sources and compiling them on the server would be a better idea than compiling them locally into a JAR and then deploying it on the server? It's on the JVM, take advantage of it. - Zoltán
@Zoltán Because the Server(s) may be located in another country, only accessible via VPN. Now the total size of the source is several hundred MB and if I need to make small changes, I wouldn't have to copy the entire .jar over the slow connection again. - Michael Lang

1 Answers

2
votes

I would strongly suggest that you use a build tool. Many open source projects use sbt (http://www.scala-sbt.org/). You can use an sbt plugin (https://github.com/sbt/sbt-assembly) to create a fat jar with all your dependencies.

You can also use Maven and Gradle.