简体   繁体   English

sbt-assembly多模块项目?

[英]sbt-assembly multimodule project?

My project is separated on multiple parts: * core project * utils (as example) project 我的项目分为多个部分:*核心项目* utils(例如)项目

Both of them have some unit-tests, and "core project" relies on code in "utils" project by "dependsOn" mechanism of sbt. 两者都有一些单元测试,“核心项目”依靠sbt的“ dependsOn”机制依赖“ utils”项目中的代码。

I am using sbt-assembly plugin for building "uber-jar"/"fat-jar", but sbt assembly task does`t run test on utils project - which is what I am trying to achieve (I can not see any tests from "utils project" in logs) 我正在使用sbt-assembly插件来构建“ uber-jar” /“ fat-jar”,但是sbt assembly任务并未在utils项目上运行测试-这是我要实现的目标(我看不到来自日志中的“ utils项目”)

Changing "dependsOn" to "aggregate" introduce new problem: 将“ dependsOn”更改为“ aggregate”会引入新问题:

sbt assembly aggregate deduplicate sbt程序集聚合重复数据删除

something similar to this issue-on-github 类似于这个在github上的问题


So my question is how to organize multimodule project which can be assembled by sbt-assembly and all of the tests are executed during assembly task? 因此,我的问题是如何组织可以通过sbt-assembly组装的多模块项目,并在组装任务期间执行所有测试?

My guess is that you should have both dependsOn and aggregate relationships between your subprojects. 我的猜测是,您应该在子项目之间同时具有dependsOn和聚合关系。 They are not mutually exclusive, only serve different purposes. 它们不是互斥的,仅用于不同的目的。

DependsOn introduces code dependency, so if core depends on utils it means that you can reference types from utils in core. DependsOn引入了代码依赖性,因此,如果core依赖utils,则意味着您可以从core中的utils引用类型。

Aggregate introduces task dependency. 聚合引入了任务依赖性。 That means if you execute compile or test on core and it aggregates utils then the task will be executed on both subprojects. 这意味着,如果您在核心上执行编译或测试,并且聚合了utils,则该任务将在两个子项目上执行。

Problems with deduplicate are another beast - it means, that there are duplicates in resources or classes when attempting to create one jar. 重复数据删除的问题是另一回事-这意味着,尝试创建一个jar时,资源或类中存在重复数据。 The reasons for this may be various and you can tackle them by verifying the library dependencies in the build or creating MergeStrategy - https://github.com/sbt/sbt-assembly#merge-strategy 造成这种情况的原因可能多种多样,您可以通过验证构建中的库依赖关系或创建MergeStrategy来解决它们-https: //github.com/sbt/sbt-assembly#merge-strategy

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

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