如何设置 sbt-assembly 以包含具有运行时范围的 jar?默认情况下不这样做的理由是什么?
问问题
1224 次
2 回答
1
我的测试表明该插件确实包含具有范围的依赖项,runtime
如以下示例所示。
项目/plugins.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
构建.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.
罐子验证:
/cygdrive/c/dev/sandbox/runtime-assembly
$ jar -tf target/scala-2.10/runtime-assembly-assembly-0.1-SNAPSHOT.jar | grep logback | wc -l
592
于 2014-07-15T14:47:59.237 回答
1
现在正在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 的人来说,上面的 sbt-0.13+ 格式:=
对应于旧的 pre-sbt-0.13 格式,:=
如下所示:
fullClasspath in assembly <<= (fullClasspath in Runtime)
于 2014-07-16T04:38:44.967 回答