问题描述
我正在创建一个具有以下结构的多模块sbt项目:
I am creating a multi-module sbt project, with following structure:
<root>
----build.sbt
----project
----Build.scala
----plugins.sbt
----common
----LoggingModule
LoggingModule
是一个Play Framework项目,而common
是一个简单的Scala项目.
LoggingModule
is a Play Framework project, while common
is a simple Scala project.
在plugins.sbt
中:
resolvers += "Typesafe repo" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.3")
虽然我在build.sbt
中拥有此功能,但一切正常,并且可以识别PlayScala
:
While I have this in build.sbt
, all works fine and it recognises PlayScala
:
name := "Multi-Build"
lazy val root = project.in(file(".")).aggregate(common, LoggingModule).dependsOn(common, LoggingModule)
lazy val common = project in file("common")
lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)
但是,我将其立即放入project/Build.scala
而不是如下的"build.sbt":
However as soon I put this in project/Build.scala
instead of `build.sbt' as follows:
object RootBuild extends Build {
lazy val root = project.in(file("."))
.aggregate(common, LoggingModule)
.dependsOn(common, LoggingModule)
lazy val common = project in file("common")
lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)
...//other settings
}
它生成错误为:
not found: value PlayScala
lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)
^
如何解决该问题?
推荐答案
这只是缺少的导入内容.
It's just a missing import.
在.sbt
文件中,默认情况下会自动导入一些内容:扩展Plugin
的对象的内容,以及AutoPlugin
s中的(> = 0.13.5)autoImport
字段. PlayScala
就是这种情况.
In .sbt
files, some things are automatically imported by default: contents of objects extending Plugin
, and (>= 0.13.5) autoImport
fields in AutoPlugin
s. This is the case of PlayScala
.
在Build.scala
文件中,将应用常规的Scala导入规则.因此,您必须更加明确地导入内容.在这种情况下,您需要import play.PlayScala
(或直接使用.enabledPlugins(play.PlayScala)
).
In a Build.scala
file, normal Scala import rules apply. So you have to import things a bit more explicitly. In this case, you need to import play.PlayScala
(or use .enabledPlugins(play.PlayScala)
directly).
这篇关于为什么sbt报告“未找到:值PlayScala"? build.sbt工作时,使用Build.scala与?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!