简体   繁体   English

sbt-onejar和多项目构建

[英]sbt-onejar and multi-project build

When using oneJar to package a multi project sbt build, project dependencies are not bundled into the jar. 当使用oneJar打包多项目sbt构建时,项目依赖项不会捆绑到jar中。 My setting is the following: 我的设置如下:

foo/build.sbt          (top-level build.sbt)
foo/src/               (sources of the root project)
foo/gui/build.sbt      (project 'build' definition)
foo/gui/src            (sources of the 'gui' project)

The build definitions are: 构建定义为:

// foo/build.sbt

name := "foo"

version := "0.0.1"

scalaVersion := "2.10.4"

lazy val root = project.in( file(".") )

lazy val gui = project.in( file("gui") ).dependsOn( root )

[...]

//foo/gui/build.sbt

name := "foo-gui"

seq(com.github.retronym.SbtOneJar.oneJarSettings: _*)

[...]

When calling oneJar on the gui project everything seems to run fine, but the classes of the root project are not included in the jar (although the library dependencies are). gui项目上调用oneJar时,一切似乎运行良好,但是jar项目中不包含root项目的类(尽管库相关性已包含)。 Is there any fix ? 有什么解决办法吗?

I never tried a light configuration as you but shouldn't you put the oneJar settings in the root sbt file? 我从来没有尝试过像您这样的简单配置,但是您不应该将oneJar设置放在根sbt文件中吗? You want to package the root and include guy right? 您想打包根目录并包含Guy吗?

I tried something similar for the first time today and started with oneJar but when using a full sbt configuration the compiler complained that settings were a Seq(_) and sbt expected a single setting or something like that. 我今天第一次尝试类似的方法,并从oneJar开始,但是当使用完整的sbt配置时,编译器抱怨设置是Seq(_),而sbt期望使用单个设置或类似的设置。 I switched to sbt-assembly and it worked. 我切换到sbt-assembly ,它起作用了。

sbt-oneJar has not been updated for 2 years while sbt-assembly was recently updated. sbt-oneJar已有两年未更新,而sbt-assembly最近已更新。 I'm not sure which one is preferred but I'd rather use an active tool. 我不确定哪个是首选,但我宁愿使用一个活跃的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM