【发布时间】:2013-09-21 05:57:02
【问题描述】:
这是一个例子build.sbt:
import AssemblyKeys._
assemblySettings
buildInfoSettings
net.virtualvoid.sbt.graph.Plugin.graphSettings
name := "scala-app-template"
version := "0.1"
scalaVersion := "2.9.3"
val FunnyRuntime = config("funnyruntime") extend(Compile)
libraryDependencies += "org.spark-project" %% "spark-core" % "0.7.3" % "provided"
sourceGenerators in Compile <+= buildInfo
buildInfoPackage := "com.psnively"
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, target)
assembleArtifact in packageScala := false
val root = project.in(file(".")).
configs(FunnyRuntime).
settings(inConfig(FunnyRuntime)(Classpaths.configSettings ++ baseAssemblySettings ++ Seq(
libraryDependencies += "org.spark-project" %% "spark-core" % "0.7.3" % "funnyruntime"
)): _*)
目标是拥有 spark-core "provided",因此它及其依赖项不包含在程序集工件中,而是将它们重新包含在 run- 和 test 相关任务的运行时类路径中。
似乎使用自定义范围最终会有所帮助,但我对如何实际使默认/全局运行/测试任务使用自定义 libraryDependencies 并希望覆盖默认值感到困惑。我尝试过的方法包括:
(run in Global) := (run in FunnyRuntime)
等都无济于事。
总结一下:这感觉本质上是对 web 案例的概括,其中 servlet-api 在“已提供”范围内,并且运行/测试任务通常派生一个 servlet 容器,该容器确实为运行代码提供了 servlet-api .这里唯一的区别是我没有分叉一个单独的 JVM/环境。我只想手动增加这些任务的类路径,有效地“撤消”“提供”的范围,但以一种继续从组装工件中排除依赖的方式。
【问题讨论】:
-
我不需要“添加回”使用 sbt run 或 intellij 运行的“提供的”依赖项。看看这个:github.com/dportabella/spark-examples
标签: scala sbt sbt-assembly