打包和部署 Scala 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3026911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Packaging and Deploying Scala Applications
提问by Simon Morgan
What is the simplest way to package a Scala application for use on a desktop PC? I'm guessing that would be in the form of a jar file.
打包 Scala 应用程序以在台式机上使用的最简单方法是什么?我猜这将是一个 jar 文件的形式。
At the moment I'm using SBT to compile and run programs
目前我正在使用 SBT 来编译和运行程序
I'd be interested in solutions for machines that have Scala installed (and the library in their classpath), as well as those that only have Java.
我对安装了 Scala 的机器(及其类路径中的库)以及只有 Java 的机器的解决方案感兴趣。
采纳答案by Vasil Remeniuk
The simplest (and the most consistent) way to package a Scala application, is packaging into a JAR (like you do with normal Java applications). As long as JAR consists of standard compiled Java classes, you may run "Scala" JAR, even if you don't have Scala runtime at the box (all you need is a Java Runtime and scala-lang.jar on the classpath). You may specify the main class (gateway to functionalities of your application) in the manifast
打包 Scala 应用程序的最简单(也是最一致的)方法是打包成 JAR(就像您对普通 Java 应用程序所做的那样)。只要 JAR 包含标准编译的 Java 类,您就可以运行“Scala”JAR,即使您没有安装 Scala 运行时(您只需要一个 Java 运行时和类路径上的 scala-lang.jar)。您可以在清单中指定主类(应用程序功能的网关)
Main-Class: mypackage.MyClass
so that you'll be able to call it only passing a JAR name to java.exe.
这样您就可以调用它,只将 JAR 名称传递给 java.exe。
java -jar myjar.jar
You may specify the main classin SBT project definition.
您可以在 SBT 项目定义中指定主类。
回答by liangzan
http://www.scala-sbt.org/sbt-native-packager/index.html
http://www.scala-sbt.org/sbt-native-packager/index.html
The plugin allows you to package in a variety of formats(zip, tar, deb, dmg, msi, etc) and in different archtypes.
该插件允许您以各种格式(zip、tar、deb、dmg、msi 等)和不同的架构类型打包。

