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

查看:31
本文介绍了如何从另一个 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:gitCoreLibrary is not contained in build root C:gitApplicationA

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

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天全站免登陆