2

我正在尝试根据https://play.lighthouseapp.com/projects/82401/tickets/193-javascript-require-support-in-non-minimized-files的说明修改闭包编译器选项。

我还需要添加一个解析器。

val defaultOptions = new CompilerOptions()
defaultOptions.closurePass = true
CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(defaultOptions)
defaultOptions.setProcessCommonJSModules(true)
val root = new java.io.File(".")
defaultOptions.setCommonJSModulePathPrefix(root.getCanonicalPath + "/app/assets/javascript/")
defaultOptions.setPrettyPrint(true)

def optClosureValues = Option(System.getProperty("closureoff")).filter(_ != "").map {
dev =>
  println("using alternative closure compiler")
  closureCompilerSettings(defaultOptions)
}.getOrElse(Seq.empty)


val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
optClosureValues:_*,
resolvers += ("Morphia" at "http://morphia.googlecode.com/svn/mavenrepo/")
)

这给出了一个错误

Build.scala:35: no `: _*' annotation allowed here
[error] (such annotations are only allowed in arguments to *-parameters)
[error]     optClosureValues:_*,
[error]                     ^
[error] one error found

这里的正确语法是什么?

4

1 回答 1

2

你可能可以这样写:

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  optClosureValues ++
  Seq(resolvers += ("Morphia" at "http://morphia.googlecode.com/svn/mavenrepo/")): _*
)

我使用最新的 2.1-SNAPSHOT 在我的机器上确认了上述工作。

于 2012-07-23T18:52:44.030 回答