如何设置sbt-assembly以包含具有运行时范围的jar?默认不这样做的理由是什么?
答案 0 :(得分:2)
现在正在sbt/sbt-assembly#120下讨论。
sbt-assembly旨在从Runtime
配置连接完整的类路径。它的编码如下:
fullClasspath in assembly <<= fullClasspath or (fullClasspath in Runtime),
对于Spark,无论出于何种原因fullClasspath
都已连接,因此可能会产生干扰。 sbt-assembly包含fullClasspath
的原因我认为现在是历史性的,所以我可能会摆脱“fullClasspath或”部分。正如该问题所述,当前的解决方法很可能是:
fullClasspath in assembly := (fullClasspath in Runtime).value
对于那些学习上述带有:=
的sbt-0.13 +格式的人来说,对应于带有:=
的旧的pre-sbt-0.13格式,如下所示:
fullClasspath in assembly <<= (fullClasspath in Runtime)
答案 1 :(得分:1)
我的测试显示该插件使用runtime
范围执行包含依赖关系,如以下示例所示。
<强>项目/ plugins.sbt 强>
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
<强> build.sbt 强>
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.2" % "runtime"
assemblySettings
这是一个示例会话:
> about
[info] This is sbt 0.13.6-SNAPSHOT
[info] The current project is {file:/C:/dev/sandbox/runtime-assembly/}runtime-assembly 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, org.sbtidea.SbtIdeaPlugin, de.johoop.jacoco4sbt.JacocoPlugin, com.timushev.sbt.updates.UpdatesPlugin, sbtassembly.Plugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4
> assembly
[info] Updating {file:/C:/dev/sandbox/runtime-assembly/}runtime-assembly...
[info] Resolving org.jacoco#org.jacoco.agent;0.6.4.201312101107 ...
[info] downloading http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar ...
[info] [SUCCESSFUL ] ch.qos.logback#logback-classic;1.1.2!logback-classic.jar (1122ms)
[info] downloading http://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar ...
[info] [SUCCESSFUL ] ch.qos.logback#logback-core;1.1.2!logback-core.jar (1313ms)
[info] Done updating.
[info] Including: slf4j-api-1.7.6.jar
[info] Including: logback-classic-1.1.2.jar
[info] Including: logback-core-1.1.2.jar
[info] Including: scala-library.jar
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Strategy 'discard' was applied to a file
[info] SHA-1: 0f520cdfc30de8ced8408a3c25b326b3ff5afda8
[info] Packaging C:\dev\sandbox\runtime-assembly\target\scala-2.10\runtime-assembly-assembly-0.1-SNAPSHOT.jar ...
[info] Done packaging.
Jar验证:
/cygdrive/c/dev/sandbox/runtime-assembly
$ jar -tf target/scala-2.10/runtime-assembly-assembly-0.1-SNAPSHOT.jar | grep logback | wc -l
592