我有一个多项目sbt构建,我想使用https://github.com/softprops/coffeescripted-sbt将我的coffeescript编译为javascript,但它没有执行任务。
代码取自https://github.com/jeffmay/angular-play-multimodule-seed/tree/stackoverflow-17289043
即使不推荐,我也会将项目目录中的build.sbt文件与我的项目对象混合,以测试此插件是否有效。
在build.sbt
:
seq(coffeeSettings: _*)
我跑的时候:
$ sbt
[info] Loading project definition from /Users/jeffmay/code/righttrack/project
[info] Set current project to root (in build file:/Users/jeffmay/code/righttrack/)
> coffee
[success] Total time: 0 s, completed Jun 24, 2013 11:40:37 PM
> show coffee
[info] ArrayBuffer()
[success] Total time: 0 s, completed Jun 24, 2013 11:40:52 PM
> project web
[info] Set current project to web (in build file:/Users/jeffmay/code/righttrack/)
[web] $ coffee
[error] Not a valid command: coffee
[error] No such setting/task
[error] coffee
[error] ^
[web] $
ArrayBuffer()
是什么意思?这是一个沉默的失败(coffeescript返回最后一个return;
null
的表达式吗?)
在某些情况下,我的构建就像这样......
在project/plugins.sbt
:
// SBT community plugin resolver
resolvers += Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
// CoffeeScript compiler plugin
addSbtPlugin("me.lessis" % "coffeescripted-sbt" % "0.2.3")
在project/Modules.scala
(我的构建对象)中:
import sbt._
object Modules extends Build {
lazy val root = RootModule.project
lazy val api = ApiModule.project
lazy val web = WebModule.project
}
在project/WebModule.scala
:
object WebModule extends BaseModule {
// ... libraries dependencies and stuff
override def project = play.Project(moduleName, moduleVersion, libraries, file(location),
moduleSettings ++
Seq((resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "src" / "main" / "coffee"))
)
}
我使用project/BaseModule.scala
来消除每个模块的常见元素的混乱,但它没有做任何花哨的事情。
我删除了build.sbt
内容,并通过添加以下内容Build.scala
project/WebModule.scala
添加:
override def project = play.Project(moduleName, moduleVersion, libraries, file(location),
moduleSettings ++
coffeeSettings ++ // With the settings moved from build.sbt
Seq((resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "src" / "main" / "coffee"))
)
然后我给它一个旋转
$ sbt
[info] Loading project definition from /Users/jeffmay/code/righttrack/project
[info] Set current project to root (in build file:/Users/jeffmay/code/righttrack/)
> coffee
[error] Not a valid command: coffee
[error] No such setting/task
[error] coffee
[error] ^
> project web
[info] Set current project to web (in build file:/Users/jeffmay/code/righttrack/)
[web] $ coffee
[success] Total time: 0 s, completed Jun 25, 2013 12:08:36 AM
[web] $ show coffee
[info] ArrayBuffer()
[success] Total time: 0 s, completed Jun 25, 2013 12:08:40 AM
运行coffee命令后,我没有看到任何变化。任何想法是什么问题?
谢谢!
答案 0 :(得分:0)
有关详细信息,请参阅我的软对话对话框:https://github.com/softprops/coffeescripted-sbt/issues/17
上述代码存在三个问题,一个改进。
我没有将我的网络项目聚合到根项目中。
我没有设置在哪里找到咖啡脚本文件。
Play使用“./app”作为sourceDirectory
,所以当我添加看似“正确”的目录路径时
sourceDirectory in (Compile, CoffeeKeys.coffee) <<= sourceDirectory { _ / "main" / "coffee" }
它在“./app/src/main/coffee”中搜索,但不存在
我能够通过让编译器管理./public
目录来改进这个例子,这样它就可以将已编译的javascript源放在Angular Seed Project的推荐public/js
目录中。
您可以在此处查看完整的种子项目示例:https://github.com/jeffmay/angular-play-multimodule-seed