我发现有必要将我已经使用一段时间的代码重新组织到一个sbt多项目中。我已经参考了两个来源作为示例:
基于以上两个内容,是我项目的当前结构:
[vgorcinschi@localhost Learning Concurrent Programming Test]$ tree -L 2
.
├── build.sbt
├── chapter01_introduction
│ ├── build.sbt
│ └── src
├── chapter02_concurrency_on_jvm
│ ├── build.sbt
│ └── src
├── chapter03_traditional_concurrency
│ ├── build.sbt
│ └── src
└── project
├── build.properties
├── Common.scala
├── Dependencies.scala
└── target
8 directories, 7 files
我会按照您的建议急于发布其余配置文件的详细信息,但目前与错误最相关的似乎是根build.sbt
。这是它的内容:
name := "learning concurrent programming in scala"
organization in ThisBuild := "ca.vgorcinschi"
scalaVersion in ThisBuild := "2.12.6"
import Dependencies._
import Common
version := "0.0.1"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
lazy val chapter01_introduction = project.
settings(Common.settings: _*).
settings(libraryDependencies ++= Dependencies.akkaDependencies)
lazy val chapter02_concurrency_on_jvm = project.
dependsOn(chapter01_introduction).
settings(Common.settings: _*,
mainClass in Compile := Some("org.learningconcurrency.concurrency_on_jvm.PriorityTaskPool_Ex8")).
settings(libraryDependencies ++= Dependencies.commonDependencies)
lazy val chapter03_traditional_concurrency = project.
dependsOn(chapter01_introduction).
settings(Common.settings: _*).
settings(libraryDependencies ++= Dependencies.commonDependencies)
lazy val root = (project in file(".")).
aggregate(chapter01_introduction, chapter02_concurrency_on_jvm, chapter03_traditional_concurrency)
当我将其导入Intellij IDEA(2017.3,同时具有Scala和SBT插件)时,出现此错误:build.sbt]:8: '.' expected but ';' found.
出于兴趣的考虑,这是整个堆栈跟踪:
Error while importing sbt project:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=2048M; support was removed in 8.0
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /home/vgorcinschi/.sbt/1.0/plugins
[info] Updating ProjectRef(uri("file:/home/vgorcinschi/.sbt/1.0/plugins/"), "global-plugins")...
[info] Done updating.
[info] Loading project definition from /home/vgorcinschi/ideaProjects/Learning Concurrent Programming Test/project
[info] Updating ProjectRef(uri("file:/home/vgorcinschi/ideaProjects/Learning%20Concurrent%20Programming%20Test/project/"), "learning-concurrent-programming-test-build")...
[info] Done updating.
[info] Compiling 2 Scala sources to /home/vgorcinschi/ideaProjects/Learning Concurrent Programming Test/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.
[error] [/home/vgorcinschi/ideaProjects/Learning Concurrent Programming Test/build.sbt]:8: '.' expected but ';' found.
Invalid response.
我很乐意告诉您有关问题是在intellij还是sbt方面,我们将提供任何帮助或建议。
答案 0 :(得分:0)
我发现了问题所在(很好的问题 s ):
import Common
。删除它可以解决该错误。 然后我又抱怨在子项目中用于追加到通用设置的语法:
设置(通用设置:_ *, 编译中的mainClass:= Some(“ org.learningconcurrency.concurrency_on_jvm.PriorityTaskPool_Ex8”))
我将不得不弄清楚如何正确地做它。到目前为止,将其删除有助于我无误地导入项目。
最后,这是对我有用的工作根目录build.sbt:
name := "learning concurrent programming in scala"
organization in ThisBuild := "ca.vgorcinschi"
scalaVersion in ThisBuild := "2.12.6"
version := "0.0.1"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
lazy val chapter01_introduction = project.
settings(Common.settings: _*).
settings(libraryDependencies ++= Dependencies.akkaDependencies)
lazy val chapter02_concurrency_on_jvm = project.
dependsOn(chapter01_introduction).
settings(Common.settings: _*).
settings(libraryDependencies ++= Dependencies.commonDependencies)
lazy val chapter03_traditional_concurrency = project.
dependsOn(chapter01_introduction).
settings(Common.settings: _*).
settings(libraryDependencies ++= Dependencies.commonDependencies)
lazy val root = (project in file(".")).
aggregate(chapter01_introduction, chapter02_concurrency_on_jvm, chapter03_traditional_concurrency)