简体   繁体   English

sbt子项目:取决于

[英]sbt subProject: dependsOn

I have the following build.sbt with two sub projects. 我有以下带有两个子项目的build.sbt。 Everything compiles and runs fine. 一切都可以编译并正常运行。 One is a thin scala play project. 一个是瘦的scala游戏项目。 dataextractor has a lot of util classes I want to call in the play project. dataextractor有很多我想在play项目中调用的util类。

However, the configurarion below still leads to the following compilation error: 但是,下面的配置仍然会导致以下编译错误:

[error] /Users/foo.bar/_vws/com.corp.enablement.scripts/sirf_extract_serve/tools_sirf_server/app/corp/tools/es_result_server/service/SystemInitializer.scala:6:21: object dataextraction is not a member of package corp.tools [error] import corp.tools.dataextraction.providers.confluence [错误] /Users/foo.bar/_vws/com.corp.enablement.scripts/sirf_extract_serve/tools_sirf_server/app/corp/tools/es_result_server/service/SystemInitializer.scala:6:21:对象数据提取不是包的成员corp.tools [错误]导入corp.tools.dataextraction.providers.confluence

This is my first sbt multi-project. 这是我的第一个sbt多项目。 Advice would be genuinley appreciated 忠告将不胜感激

lazy val tools_dataextractor = (project in file("tools_dataextractor")).settings(
  Defaults.itSettings,
  libraryDependencies += scalatest % "it,test",
  name := "corp_tools_dataextractor",
  version := "0.1",
  mainClass in Compile := Some("corp.tools.ExtractionStartUp")
  )

lazy val tools_sirf_server = (project in file("tools_sirf_server")).settings(

  ).enablePlugins(PlayScala).dependsOn(tools_dataextractor)


lazy val root = (project in file("."))
    .aggregate(tools_dataextractor, tools_sirf_server)

The configuration looks good. 配置看起来不错。

2 possibilities what the problem might be: 问题可能是2种可能性:

  • You are in a sbt-console and haven't reloaded the console after you changed build.sbt 您位于sbt-console并且在更改build.sbt之后尚未重新加载控制台
  • You work with Intellij and did not reload the sbt projects 您使用Intellij,但没有重新加载sbt projects

If this does not help - adjust your question with the steps you take. 如果这样做没有帮助,请按照您的步骤调整问题。

OK, the answer is neophyte error. 好的,答案是新手错误。 I had a build.sbt in the root and a build.sbt in each sub project (which is permissible). 我在根目录中有一个build.sbt ,在每个子项目中都有一个build.sbt (允许)。

Everything will built fine.... Until I started adding dependencies from one sub-project to another. 一切都会很好。...直到我开始将依赖关系从一个子项目添加到另一个子项目。 In this case, the super build.sbt " dependsOn " is ignored and compilation errors occur. 在这种情况下,鲁能build.sbtdependsOn ”被忽略,并且发生编译错误。

Side note, the main reason for keeping sub-project build.sbt was simply laziness. 旁注,保留子项目build.sbt仅仅是懒惰。 It took half a day to get everything working in a single build.sbt at the root level. 花了半天的时间才能在根目录下的单个build.sbt所有工作正常。 However, it is defintiely worth the effort. 但是,绝对值得付出努力。

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

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