如何从另一个 sbt 项目引用外部 sbt 项目? [英] How to reference external sbt project from another sbt project?

查看:63
本文介绍了如何从另一个 sbt 项目引用外部 sbt 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Scala 应用程序和公共核心库进行了以下设置:根

I have the following setup of a Scala application and a common core library: root

 -> /ApplicationA
   -> /project
     -> /build.sbt
 -> /CoreLibrary
   -> /project
     -> /build.sbt

我想添加一个从 ApplicationA 到 CoreLibrary à la Eclipse 项目引用的引用,这样每次 CoreLibrary 更改时 ApplicationA 也会被构建.我已经为 ApplicationA 尝试了 build.Scala 的以下内容:

I want to add a reference from ApplicationA to CoreLibrary à la Eclipse project reference, so that every time CoreLibrary changes ApplicationA is built as well. I´ve tried the following contents of build.Scala for ApplicationA:

  val core = Project(
      id = "platform-core",
      base = file("../CoreLibrary"))

  val main = Project(id = "application, base = file(".")).dependsOn(core)

然而,在编译 ApplicationA 时,SBT 抱怨一个依赖项只能是一个子目录!!:

However, when compiling ApplicationA SBT complains that a dependency can only be a subdirectory!!:

java.lang.AssertionError: assertion failed: Directory C:\git\CoreLibrary is not contained in build root C:\git\ApplicationA

这看起来很简单,拥有这个项目依赖的正确方法是什么?

This seems completely straightforward, what's the correct way of having this project dependency?

推荐答案

您可以像这样对您的项目进行源依赖:

You can do a source dependency on your project like that :

 lazy val core = RootProject(file("../CoreLibrary"))

 val main = Project(id = "application", base = file(".")).dependsOn(core) 

我有一个多模块播放构建的工作示例:https://github.com/ahoy-jon/play2MultiModule/blob/master/playapp/project/Build.scala

I have a working example with a multimodule play build : https://github.com/ahoy-jon/play2MultiModule/blob/master/playapp/project/Build.scala

但我认为这样做的正确方法(取决于您的上下文)是创建一个

But I think the proper way (it depends of your context) of doing it is to create a

 -> /project/
   -> Build.scala
 -> /ApplicationA
   -> /project
     -> /build.sbt
 -> /CoreLibrary
   -> /project
     -> /build.sbt

引用两个项目以及它们之间的依赖关系.

referencing the two projects and the dependencies between them.

这篇关于如何从另一个 sbt 项目引用外部 sbt 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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