gpt4 book ai didi

scala - SBT项目导航

转载 作者:行者123 更新时间:2023-12-04 04:45:19 25 4
gpt4 key购买 nike

我有以下版本:

  lazy val stampleSearchProject = RootProject(file("../stample-search"))


lazy val main = play.Project(appName, appVersion, appDependencies)
.dependsOn(stampleSearchProject)
.settings(defaultScalaSettings:_*)
.settings( ......... )

戳搜索项目有一个 build.sbt 文件,其中包含 name := "stample-search"
我在 SBT 文档中找到了:

Navigating projects interactively: At the sbt interactive prompt, type projects to list your projects and project to select a current project. When you run a task like compile, it runs on the current project. So you don't necessarily have to compile the root project, you could compile only a subproject.



但是 SBT 文档不使用 RootProject 而是使用 Project (这似乎需要在根项目中使用项目路径,我的意思是我不能使用 ../my-project )

所以我尝试了这个。
[Stample] $ projects
[info] In file:/home/sebastien/Bureau/Stample/stample-web/
[info] * Stample
[info] In file:/home/sebastien/Bureau/Stample/stample-search/
[info] default-ccdbaa

所以它似乎列出了两个项目,但我想知道这个名字是从哪里来的 default-ccdbaa
然后我尝试使用项目命令
[Stample] $ project Stample
[info] Set current project to Stample (in build file:/home/sebastien/Bureau/Stample/stample-web/)

[Stample] $ project default-ccdbaa
[error] Invalid project name 'default-ccdbaa' in build file:/home/sebastien/Bureau/Stample/stample-web/ (type 'projects' to list available projects).

[Stample] $ project stample-search
[error] Invalid project name 'stample-search' in build file:/home/sebastien/Bureau/Stample/stample-web/ (type 'projects' to list available projects).

它似乎不起作用。有人可以解释我的构建有什么问题吗?

最佳答案

有关详细信息,您可能需要阅读 Full Configuration (Draft) : Project Relationships

There are three kinds of project relationships in sbt. These are described by execution, classpath, and configuration dependencies. ...


RootProject定义项目引用,而不是子项目。所以你有效地创建了一个源级依赖,但你不能切换到它。更好的方法是使用普通 Multi-Project build .
import sbt._
import Keys._

object HelloBuild extends Build {
lazy val root = Project(id = "hello",
base = file(".")) aggregate(foo, bar)

lazy val foo = Project(id = "hello-foo",
base = file("foo"))

lazy val bar = Project(id = "hello-bar",
base = file("bar"))
}

关于scala - SBT项目导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18290102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com