SBT:依赖其他SBT项目而不发布 [英] SBT: Dependency On Other SBT Project Without Publishing

查看:100
本文介绍了SBT:依赖其他SBT项目而不发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组松散相关的组件,其中一些依赖于其他组件。为了具体起见,假设我们具有 common, a和 b组成部分。 common没有任何依赖关系,但是所有其他项目都使用 common。此外, a取决于 b。所有组件都是用Scala编写的,我想使用sbt来构建它们。

I have a set of loosely related components where some of these depend on others. For concreteness, lets assume we have components "common", "a" and "b". "common" does not have any dependencies, but all other projects use "common". Furthermore, "a" depends on "b". All components are written in Scala, and I would like to use sbt to build them.

具有以下属性将很不错:

The following properties would be nice to have:


  1. 多个人在不同的项目上工作,这就是为什么我们不想有一个存储库,而每个项目只有一个存储库。

  2. 构建项目应该很容易,并且所有依赖项都应该自动构建(如有必要)。也就是说,如果我修改 common然后再构建 b,则应该首先构建 common,然后继续构建 b。

  3. 能够拥有所有项目在IDE中,这样重构和类似的IDE任务可以正常工作,并且所有受影响的项目都可以正确更改。

看到,在sbt中具有这种依赖关系有两种可能性;我们要么使用子项目,要么使用托管依赖项(将其推送到某个地方,例如本地)。但是,这两个选项似乎都没有提供上述(1)或(2)。特别是

As far as I can see, there are two possibilities to have dependencies of this kind in sbt; either we use sub-projects, or use a managed dependency (that is pushed somewhere, e.g., locally). However, it seems that both of these options don't provide either (1) or (2) above. In particular


  • 使用子项目会迫使我们使用单个存储库,因为所有子项目都必须位于主项目的子目录中项目。

  • 在本地发布项目并使用托管依赖项很麻烦,因为先更改并创建 b,然后再构建 b,才能选择 common中的更改(如果先构建并发布了该项目) 。我可以看到托管依赖项在许多情况下都很有用,但是对于我们的特定用例,它们似乎运行不佳。我们经常从事多个项目,并同时更改它们。因此,不得不发布通常看起来过于复杂。

真的没有办法说一个sbt项目依赖于另一个sbt吗?

Is there really no way to say that an sbt project depends on another sbt project at a certain (relative) location, and having sbt figure out when to build the dependency?

推荐答案

在SBT中,您可以使用sbt来确定何时建立依赖项?

With SBT you can use source dependencies.

lazy val root = Project("root", file("."), settings = ...) dependsOn(dispatchLiftJson)

lazy val dispatchLiftJson = uri("git://github.com/dispatch/dispatch-lift-json#0.1.0")

在此示例中,它将从git中获取。尽管我找不到示例,但您也许可以指定磁盘上的文件位置。可能

It will fetch from git in this example. You may be able to specify a file location on disk, although I can't find examples. Possibly

lazy val dep = file("/path/to") 

lazy val dep = uri("file:///path/to")

我正在为此苦苦挣扎-目前我使用可以正常工作的publish-local方法。

I'm struggling with this myself - at the moment im using the publish-local method which is working ok.

这篇关于SBT:依赖其他SBT项目而不发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆