9

今天我集成sbt-native-packager到我的scala项目中,主要是为了生成方便的执行脚本和/或包。

现在,我添加到我的build.sbt行:

packageArchetype.java_application

和我的plugins.sbt

resolvers += "sbt-plugins" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.0-RC2")

当我调用时,sbt stage我得到了target/universal/stage目录,但只有lib那里,没有bin脚本(根据http://www.scala-sbt.org/sbt-native-packager/GettingStartedApplications/MyFirstProject.html应该创建)。

我是否需要添加其他内容来获取bin带有脚本的目录?

4

2 回答 2

18

问题是在我的项目中我有多个主要课程。在build.sbt我有:

Keys.mainClass in (Compile, run) := Some("Rest")

应该是

Keys.mainClass in (Compile) := Some("Rest")

现在它完美地工作了。

于 2014-05-14T22:20:19.540 回答
1

附带说明一下,更改 mainClass 的配置会影响应用程序的 in-sbt 运行。为了将您的构建配置为在 sbt 中运行应用程序(例如在开发期间)以及创建包,您将需要 2 个 mainClass 定义(在 中build.sbt):

mainClass in Compile := Some("MyBootKernel")

mainClass in (Compile, run) := Some("MyApp")

2个主要课程是:

class MyBootKernel extends Bootable {
  def startup = { MyApp.main(Array()) }
  def shutdown = {}
}

object MyApp extends App {
    // initialize application.
}

bin 目录中的启动脚本将应用程序主类传递给 akka 微内核,它必须扩展 Bootable(然后初始化应用程序),而直接从 sbt 运行不需要启动东西(即直接应用程序)。

于 2015-02-20T11:09:02.883 回答