scala 如何将 sbt-assembly 中的非托管 JAR 添加到最终的胖 JAR?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18749406/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 05:39:38  来源:igfitidea点击:

How can I add unmanaged JARs in sbt-assembly to the final fat JAR?

scalasbtsbt-assembly

提问by Garrett Hall

My project has dependencies on a JAR file that isn't in Ivy, how can I include it directly in the final JAR output by sbt-assembly?

我的项目依赖于不在 Ivy 中的 JAR 文件,如何将它直接包含在sbt-assembly的最终 JAR 输出中?

回答by Garrett Hall

Figured out I just have to add them explicitly as unmanaged dependencies in Build.scala, they are not automatically pulled in from the libfolder. Adding this line to settings worked:

想通了我只需要将它们显式添加为 中的非托管依赖项Build.scala,它们不会自动从lib文件夹中拉入。将此行添加到设置有效:

unmanagedJars in Compile += file("lib/vertica_jdk_5.jar")

unmanagedJars in Compile += file("lib/vertica_jdk_5.jar")

回答by Eugene Yokota

For a single project setup, putting jars into libshould work. If you have multi-project setup the libdirectory would be under each subproject like app/lib.

对于单个项目设置,将 jars 放入lib应该可以工作。如果您有多项目设置,则lib目录将位于每个子项目下,例如app/lib.

回答by crockpotveggies

Just an update for those searching unmanaged dependencies: Updated documentation for 0.13.2is here: http://www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies.html

对于那些搜索非托管依赖项的人来说只是一个更新:更新的文档在0.13.2这里:http: //www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies.html